format string into column in C
First thing is, I have a .txt file containing data like this:
Lionel,Messi,35,RWF
Jordi,Alba,33,LB
Gerard,Piqué,35,CB
the idea is to read the .txt file and display the formatted data into something like this:
First Name Last Name Age Position
Lionel Messi 35 RWF
Jordi Alba 33 LB
Gerard Piqué 35 CB
this is what ive got for now:
char ch;
FILE *fptr;
printf("First Name\t Last Name\t Age\t Position");
fptr = fopen("staffList.txt", "r+");
while((ch = fgetc(fptr)) != EOF){
printf("%c", ch);
}
fclose(fptr);
getch();
the code above doesnt format the string from the file, it just prin开发者_运维技巧ts all the contents in it.
精彩评论