Q:

Output formated table with fprintf

Is there any easy way to format that table? 
I am reading a txt file using a structure. But when printing it on the screen it not organised. 
fprintf(stdout,"%d.\t'%s'\t%d\t%d\t%d\n",read.serial,read.name,read.roll,read.day1,read.day2);

I want this kind of output

No.  Name                              ID        #1 #2
1.  Sajjad Kashem                   1330273      0  1 
2.  Hafizul Karim                   1420595      1  1 
3.  Afsana Rahman                   1430458      1  1 
4.  Md. Yousuf Hosain               1510295      0  0 
5.  Md. Farhanuzzaman Reza Famous   1510303      1  0 
6.  Md. Minul Islam Talukdar        1510678      0  1 

A:

You can use formated specifier like for instance %20s will use 20 charaters regardless if the size of the string is lesser, this will be aligned right, to align left you can use %-20s:
Live demo
fprintf(stdout,"%-10s%-20s%10s%10s%10s\n\n", "No.", "Name", "ID", "#1", "#2");
fprintf(stdout,"%-10d%-20s%10d%10d%10d\n", 1, "random_name", 123456, 2, 5);
fprintf(stdout,"%-10d%-20s%10d%10d%10d\n", 2, "other_random_name", 1223, 2, 5);
fprintf(stdout,"%-10d%-20s%10d%10d%10d\n", 1, "yet_another_name", 3456980, 2, 5);  

Will output:
No.       Name                        ID        #1        #2

1         random_name             123456         2         5
2         other_random_name         1223         2         5
3         yet_another_name       3456980         2         5

