#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);
}
구조체의 선언 순서는 중요하지 않습니까? 위의 코드를 실행
[email protected]:~$ 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의 실력을 테스트 프로그램의 프로토 타입 선언과 구조체 선언의 순서는 중요하지 않습니다 말한다 다음과 같은 오류를 제공합니다. 주문이 중요한지 아닌지 묻고 싶습니다.