Programming C : printf stdio.h ex2
minimum width 5, left-justify
#include <stdio.h> int main( ) { char c = 'A'; printf("%-5c",c);
}
33 non-null, automatically
#include <stdio.h> int main( ) { char psz1[] = "this is a test"; printf("%s",psz1); }
31 non-null, automatically
#include <stdio.h> int main( ) { char psz2[] = "string text."; printf("%s",psz2); }
minimum 5 overridden, auto 33
#include <stdio.h> int main( ) { char psz1[] = "this is a test"; printf("%5s",psz1); }
minimum width 38, right-justify
#include <stdio.h> int main( ) { char psz1[] = "this is a test"; printf("%38s",psz1); }
minimum width 38, left-justify
#include <stdio.h> int main( ) { char psz2[] = "string text."; printf("%-38s",psz2); }
default ivalue width, 4
#include <stdio.h> int main( ) { int ivalue = 1234; printf("%d",ivalue); }
printf ivalue with + sign
#include <stdio.h> int main( ) { int ivalue = 1234; printf("%+d",ivalue); }
minimum 3 overridden, auto 4
#include <stdio.h> int main( ) { int ivalue = 1234; printf("%3d",ivalue); }
minimum width 5, right-justify
#include <stdio.h> int main( ) { char c = 'A'; printf("%5c",c); }