jo**********@yahoo.com wrote:
I tried to write to an output file like:
Hello USER_NAME You are visitor no:COUNT
USER_NAME : string and can be of any length bt 1 and 30.
You: The char 'Y' has fixed at column 55.
How to do this using fprintf() in making sure 'Y' is always at column
55 in this situation?
fprintf(where, "Hello %-??s You are visitor no:%d\n", USER_NAME, COUNT);
// 1234567xxxx45
// 0 55
So, the position of 'Hello' is 01. The position of 'You' is 55. You need
to figure out what to put instead of '??' in the %-??s format. How many
symbols are there between 54 (space) and 07 (where the name starts)? 47.
So, the format needs to be %-47s:
fprintf(where, "Hello %-47s You are visitor no:%d\n",
USER_NAME, COUNT);
If I got it wrong, tweak it until you get it right :-)
V