抱歉,当我尝试编译代码时,我的代码出现问题,并且我不明白需要解决什么错误:
“6:26:错误:requestformember‘txt’不是结构或 联盟”
fichero = fopen(fichero.txt,"r");
谁能帮帮我
我给你留下我的代码:
#include <stdio.h>
int calcular(char nombre[]){
FILE *fichero; int contar, maximo = 0;
char caracter;
fichero = fopen(fichero.txt,"r");
if(fichero == NULL)
printf("ERROR de Apertura");
else{
while(!feof(fichero)){
fscanf(fichero, "%c", & caracter);
if(caracter == '/n'){
if(contar > maximo)
maximo = contar;
contar = 0;
fclose(fichero);
fclose(salida);
}
}
contar++;
}
return(linea);
}
最佳答案
您将字符串文字 fichero.txt 传递给 fopen()(不带双引号),欺骗编译器认为 fichero 是一个结构体,而 txt 是该结构体的成员。
尝试:
fopen("fichero.txt", "r");
关于c - 错误: request for member ‘txt’ in something not a structure or union,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34975229/