Originally Posted by
Ash1981
2. Is there anyway to advance the cursor forward 1 position using printf, kinda like the reverse of \b. I know you could just hit the spacebar, but I was wondering if that's the only way?
If you're always working with an ANSI console or terminal, you can do non-destructive movement with the control sequence "<esc>[C", where '<esc>' is the C0 control Escape (0x1B). If you want to move 5 characters to the right, the sequence is "<esc>[5C". This is a standard ANSI control sequence. If you replace the 'C' at the end of the sequence with 'A', the cursor will move up, 'B' will move the cursor down, and 'D' will move the cursor to the left.
Originally Posted by
Ash1981
3. Is there anyway to make the cursor dissapear from the screen when using printf? Like when it sits there at the end of whatever i've displayed on the screen blinking.
Probably another ANSI control sequence, but I can't remember off the top of my head what it is. You might want to do a Google search on "ANSI control sequences" and see if anything useful shows up.
[edit]The sequence "<esc>[<selector> q", where '<esc>' is as above, '<selector>' is a number selecting the cursor rendition (0 for none, 1 for blinking block, 2 for steady block, 3 for blinking underline, 4 for steady underline), and with a space character between the selector and the 'q', works to control what the cursor looks like on some DEC terminals, but this is not supported by all ANSI displays.[/edit]
Originally Posted by
Ash1981
4. I know %10d means put 10 spaces before printing the corresponding integer (in printf), but what if you want 10 blank spaces, and you aren't using an integer, is there a way?
"%10d" means to print an integer in a field 10 characters wide (if it fits), padding with spaces if the decimal representation of the integer doesn't fill the entire 10 characters. You can use various things for whitespace, including '\t' to move to the next tab stop position.
In general, ANSI display terminal programming is fairly easy if you have a good reference for it. What I call "control sequences" you may see called "escape sequences" because they usually start with the escape character.
Not all ANSI console implementations are created equal, so you should try your program on as many of them as you can find.