#include <stdio.h>
#include <stdlib.h>
void f(struct emp);
struct emp{
char name[20];
int age;
};
int main(){
struct emp e = {"nikunj", 23} ;
f(e);
return 0;
}
void f(struct emp e){
printf("%s %d\n", e.name, e.age);
}
运行上面的代码会出现以下错误
nikunjbanka@ubuntu:~$ gcc hello2.c -o main.out
hello2.c:3:15: warning: ‘struct emp’ declared inside parameter list [enabled by default]
hello2.c:3:15: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
hello2.c: In function ‘main’:
hello2.c:10:2: error: type of formal parameter 1 is incomplete
hello2.c: At top level:
hello2.c:14:6: error: conflicting types for ‘f’
hello2.c:3:6: note: previous declaration of ‘f’ was here
但是测试你的C技能的书说,程序中原型声明和结构声明的顺序无关紧要。我想问订单是否重要?