I am trying to receive several lines of input from the user (at most 37 chars each) and write them in a file, but the result is the creation of the file with nothing there.
My current code:
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.