c代码中出错:应为标识符或';(';之前';{';标记

c代码中出错:应为标识符或';(';之前';{';标记,c,function,error-handling,compiler-errors,C,Function,Error Handling,Compiler Errors,计划简要概述(3个车身问题): #包括 #包括 #包括 双斧,ay,t; 双dt; /*其他声明,包括文件输出、N和6个命令行参数*/ ... int main(int argc,char*argv[]) { int-validinput; ... /*输入验证*/ 输出=fopen(“…”,“w”); ... /*输出验证*/ 对于(i=0;i您的函数需要一个名称!任何函数之外的代码块在C中都是没有意义的 事实上,您的示例中有几个语法/概念错误。请清理并澄清您的问题-当您这样做后,我将尝试更好

计划简要概述(3个车身问题):

#包括
#包括
#包括
双斧,ay,t;
双dt;
/*其他声明,包括文件输出、N和6个命令行参数*/
...
int main(int argc,char*argv[])
{
int-validinput;
...
/*输入验证*/
输出=fopen(“…”,“w”);
...
/*输出验证*/

对于(i=0;i您的函数需要一个名称!任何函数之外的代码块在C中都是没有意义的


事实上,您的示例中有几个语法/概念错误。请清理并澄清您的问题-当您这样做后,我将尝试更好地回答。

现在,让我们以下面的示例为例

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("hello world \n");
    return 0;
}

{
    printf("do you see this?!\n");
}
这是因为gcc编译器在
{
之前需要一个
标识符

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("hello world \n");
    return 0;
}

void function()
{
    printf("do you see this?!\n");
    return;
}

希望有帮助!

好的,谢谢。我不知道“清除”要走多远,因为我不想把我的全部代码粘贴到下面。我以前从未使用过这个网站,我如何缩进代码而不必手动放入四个空格?@user1170443:全部选中并使用
{
WMD编辑器小部件中的按钮。您的评论是错误的,应该是/*ext function…而不是*\ext function。感谢您的投票和转换我的答案。他发布了带有无效评论块的代码,并在同一行中报告了语法错误。在帮助他人之前,我会三思,以免干扰您的对话保留常见问题解答。
$ gcc q.c 
q.c:10:1: error: expected identifier or ‘(’ before ‘{’ token
$ 
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("hello world \n");
    return 0;
}

void function()
{
    printf("do you see this?!\n");
    return;
}
$ gcc q.c 
$ ./a.out 
hello world 
$