-
April 24th, 2014, 09:18 PM
#1
Backspaces in printf - formatting question
Hello.
I have one question.
For example, if we have this.
Code:
char *tmpString = "gorilla";
printf("%10s", tmpString) -> this will output 3 backspaces in front of gorrila.
However, what if I would want to declare an integer which will specifiy how many backspaces should be in front of string gorrila.
For example:
Code:
char *tmpString = "gorilla";
int countBackspaces = 10;
printf("%countBackspaces%s", tmpString) -> something like this, but i dont know how...
Is something like that even possible, i checked all manual on printf and backspaces and couldnt find the answers.
Thank you.
-
April 25th, 2014, 01:31 AM
#2
Re: Backspaces in printf - formatting question
IIRC, something like
Code:
printf("%*s", countBackspaces, tmpString );
but shouldn't this be "spaces" or "blanks" instead of backspaces?
-
April 25th, 2014, 06:17 AM
#3
Re: Backspaces in printf - formatting question
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|