2
I am trying to receive several lines of input from the user (at most they will have 37 chars each) and write them in a file, but the result is the creation of the file with nothing there.
My current code is:
void escrever_para_ficheiro(FILE *fp){
char buffer[37];
while(fgets(buffer, 37, stdin)){
fprintf(fp, "%s", buffer);
}
fclose(fp);
}
int main(){
FILE *fp = fopen("input.txt","a+");
escrever_para_ficheiro(fp);
return 0;
}
Any help would be great.
I used the G compiler++.
– Rafael
actually works, thank you
– MiguelD