开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜