main中引用的未解析的外部符号

我必须创建一个程序,该程序具有一个接受三个参数的函数charster():一个字符和两个整数。它将打印字符输入x每y行数x次。我收到语法错误LNK2019和LNK1120 main中引用的未解决的外部符号。还有IDK我做了什么导致这种情况或采取了纠正措施。

这是我的代码:

#include <stdio.h>

void charster(char n,int n_char,int n_lines);

int main(void)
{
    char n;
    int n_lines,n_chars;

    printf("Please enter a character to be printed,the amount of times it should appear,and the amount of lines that should appear: ");

    while (scanf("%c,%d,%d",&n,&n_chars,&n_lines) == 3)
    {
        charster(n,n_chars,n_lines);
    }
    return 0;


    void charster(char n,int n_lines);
    {
        int count; 

        for (count = 0; count < n_lines; count++)
        {
            putchar(n);
        }
    }
}
zhangkun863 回答:main中引用的未解析的外部符号

首先,C语言不支持嵌套函数。因此,您必须在主函数之外编写函数 charster()

您可以在主函数之上或之下编写它,因为已经声明了原型。

请查看以下代码:

"referencedTables": [
        {
          "datasetId": "DATASET”,"projectId": "PROJECTID","tableId": "TABLE"
        }
      ]
本文链接:https://www.f2er.com/3115900.html

大家都在问