I know "-" means left-aligned, "+" means right-aligned.
No, "+" flag is not relevant for the %s conversion. "+" flag
make printf show the sign (+ or -). "-" flag means left justified,
while the default is right justified.
Does %-10s mean fixed 10 character spac, allocated for that string ?
No. 10 means minimum field width.
"Characters from the array are written up to (but not including) the
terminating null character. If the precision is specified, no more than
that many characters are written."
I tried in my case sprintf(szBuffer, "%-30s %s", str1, str2), but noticed
that if str1 is more than 12 char long, the str2 will not be aligned.
example:
TestingOut1 Hello
TestingOut123 World
Well, let see
C:\Temp>type test.c
#include <stdio.h>
int main( void )
{
printf("%-30s %s\n", "TestingOut1", "Hello");
printf("%-30s %s\n", "TestingOut123", "World");
return 0;
}
C:\Temp>cl /Za test.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
test.c
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:test.exe
test.obj
C:\Temp>test
TestingOut1 Hello
TestingOut123 World
which was displayed _exactly_ as expected. Perhaps try to watch
it in Courier font...