![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,221
Rep Power: 5
![]() |
Re: printf Alignment
Well, yes, but that returned number includes things like newlines, line feeds, etc and doesn't get reset for a newline. A tab is also counted as one character, even if it effectively moves several spaces to the right. This means the return value from printf() is not related in a neat manner to the resultant position in a line - unless the data passed to it is closely controlled (eg one printf() call per line).
|
|
|
|
|
|
#12 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
Re: printf Alignment
Dunno if this helps:
The %n format specifier tells you how many characters have been output at the point %n is encountered in the formatting process. It also is a good place for hackers to attack code, but if your code is an unprivileged report process, it may be allowable. Downside: It does not carry over position information from previous printf calls. If you are writing to a file rather than the console with fprintf() maybe, then ftell() is useful if you write all fixed length strings to the output file. Otherwise you will have to use OS dependent calls to find your current cursor position. |
|
|
|
|
|
#13 | |
|
Programmer
Join Date: Oct 2007
Posts: 39
Rep Power: 0
![]() |
Re: printf Alignment
Quote:
It's call "programmer control". The programmer has to be in contol of the code s/he's writing.
__________________
Testing 001 010 011 100.... |
|
|
|
|
|
|
#14 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,221
Rep Power: 5
![]() |
Re: printf Alignment
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| printf or cout? | d_heyzie | C++ | 15 | Apr 18th, 2006 3:57 AM |
| Printing escape sequences using printf()? | bivhitscar | C | 5 | Nov 3rd, 2005 10:08 PM |
| printing "%" with printf | ivan | C | 15 | Oct 20th, 2005 7:22 AM |
| How to say the size of an array using printf ? | colt | C | 2 | May 19th, 2005 3:25 PM |
| printf() | Planet_EN | C++ | 1 | May 3rd, 2005 4:04 PM |