-1
void ex51(char *nome_ficheiro){//escrever e criar um ficheiro novo.
char frase[100];
printf("Introduza o texto que quer escrever neste ficheiro:\n");
scanf("%s",frase);
FILE *fp=fopen(nome_ficheiro,"w");
if(fp==NULL){
printf("Error!!!\n");
}else{
fprintf(fp,"%s",frase);
}
fclose(fp);
}
Whenever I give space or enter it only keeps the first word, I tried to use gets() to solve the problem, but gets() doesn’t work, causes the program to end soon.
It didn’t work, keep saving only until I give a space or enter. (i.e., save a character or a word)
– pp fernandes
@ppfernandes, I left a link at the end of the code with the example working, a look and compare with your code, it may be that there is some logic error in it.
– Brumazzi DB