In a function, data of a new student is requested with a certain format and these are saved in the csv correctly, the problem is that when entering more than one student, the data is written on the same line and does not give a line break:
The data is requested in the following format:
ballot, name, last name, age, mail, group
and they are saved in the csv correctly, the problem is that when entering another student, for example 2 students, this happens:
ticket1 name1 surname1 age1 email1 group1 ticket2 name2 surname2 age2 email2 group2
and I need this:
- ballot1 name1 surname1 age1 email1 group1
- ballot2 name2 surname2 age2 email2 group2
this is the function code
//2) Funcion Insertar
void fuins(){
char opreboot[5]={};
char c;
do
{
FILE*lista_alumnos;
lista_alumnos=fopen("lista_alumnos.csv","a+t");
system("cls");
printf("Insertar alumno a la lista del grupo 1CV2\n\n\n\n");
printf("\nIngresar datos de alumno en el siguiente formato:\n\nboleta,nombre,apllidos,edad,correo,grupo\n\nTerminal> ");
scanf("%c",&c);
while((c = getchar()) != '\n')
{
printf("%c",fputc(c,lista_alumnos));
}
fclose ( lista_alumnos );
printf("\n\nDesea agregar otro alumno? (s/n)\n\nTerminal> ");
scanf("%s",&opreboot);
}
while(strcmp(opreboot,"s")==0);
return;
}
If someone could help me, thank you very much :)
You could add a
\n
right after thewhile
one that writes the characters in the document. That way a line break will be included in the CSV file as well.Something like this (only the relevant code, with what NaCl suggested in the comments ):