I have code that intends to print some spaces after a line (to erase what might end up being here as I move the cursor).
So, I used something like this:
int some_length = 0;
char some_string[]="hello world";
printf( "%*c%s\n", some_length, ' ', some_string );
I thought it would create a “hello world”, but no, it creates a “hello world” (note that in my real code spaces are printed after the line, since the goal is to erase, not indent, I just do it is here to have a working sample).
So, is this behavior intended? Since some_length is 0, you can hope you don’t print anything, right? Is this behavior undefined, or can it be, but in the standard library (I doubt it, but ...)?
source
share