fputs - Writing a file using c program in the format of table -
i want write file in format of table using c program. using fputs write file. file looks :
[sl] [name] [school] [add] 1 abc def dav india 2 xyz lll usa
but, want output file :
[sl] [name] [school] [add] 1 abc def dav india 2 xyz lll usa
i want know there length specifier in fputs
in printf can change format of file.
i think looking fprintf
. find out more fprintf here. used same way printf
, except writes file.
edit
if string stored in different variables, use fprintf
follows :
fprintf(fp,"%-15s %-15s %-15s %-15s", "string 1", "string 2", "string 3", "string 4");
the number 15
fixed length string use (you can change based on maximum string length have or other preference). minus sign left justified string.
Comments
Post a Comment