\n in fprintf in c | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
0

\n in fprintf in c

I made a code that writes in a txt file how many times you want a letter but it doesnt go to a next line after giving the output #include <stdio.h> int main(){ int i=0; int p=0; printf("quante volte?"); scanf("%d",&p); FILE *fp; fp=fopen("file.txt","w"); while(i<p){ fprintf(fp, "a\n"); i++;} fclose(fp); return 0;}

18th May 2020, 8:56 AM
Guido Parlatore
Guido Parlatore - avatar
2 Respostas
0
The input is an int and the code is repeated so that a txt file is created and the letter "a" is repeated in the file for the number put in the input. If as an example i input 5 the file.txt file should be a a a a a But it is aaaaa instead
18th May 2020, 10:55 AM
Guido Parlatore
Guido Parlatore - avatar
0
I simply open it from the folder where it is saved with notepad
18th May 2020, 11:04 AM
Guido Parlatore
Guido Parlatore - avatar