Using format specifiers for strings and characters
Our last program is character_string.c
, and it begins as follows:
#include <stdio.h>
int main( void ) {
char aChar = 'C' ;
char* pStr = "Learn to program with C" ;
// the other code snippets go here.
}
A character value, aChar
, is defined with the C
value, and a pStr
string is defined to point to the start of the "Learn to program with C"
string.
Using the string field width, precision, alignment, and zero-filling
When printing a string with the s
conversion type, the alignment, minimum field width, and precision modifiers still apply, as follows:
printf("String output\n");
printf("Specifier Formatted Value\n");
&...