Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 31st, 2005, 10:05 PM
joy_julia446@yahoo.com
Guest
 
Posts: n/a
Default fprintf( )

Hi there,

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?

Thank you,

julia

  #2  
Old August 31st, 2005, 10:55 PM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: fprintf( )

joy_julia446@yahoo.com wrote:[color=blue]
> 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?[/color]

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
  #3  
Old August 31st, 2005, 11:05 PM
joy_julia446@yahoo.com
Guest
 
Posts: n/a
Default Re: fprintf( )

thanks.

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles