3
일부 문제를 해결하는 데 도움을주십시오.C에서 fscanf를 사용하여 문자열 검색
파일에는 다음이 포함
AAAA 111 BBB
CCC 2222 DDDD
EEEEE 33 FF
코드는 다음과 같습니다
int main() {
FILE * finput;
int i, b;
char a[10];
char c[10];
finput = fopen("input.txt", "r");
for (i = 0; i < 3; i++) {
fscanf(finput, "%s %i %s\n", &a, &b, &c);
printf("%s %i %s\n", a, b, c);
}
fclose(finput);
return 0;
}
코드는 작업을 수행합니다. 그러나 다음과 같은 오류가 발생합니다.
format «%s» expects argument of type «char *», but argument 3 has type «char (*)[10]
format «%s» expects argument of type «char *», but argument 5 has type «char (*)[10]
종류가 잘못 되었습니까? 뭐가 문제 야? 자신의 첫 번째 요소에 대한 포인터
고맙습니다! 이제 알았어! :) – kimalser