One way to read a string is to use scanf() with the %s specifier. We will also see some other ways of doing this later in this chapter. The %s specifier assigns a sequence of non-whitespace characters to the given array. As with numbers, leading whitespace is skipped. Recall that whitespace can be ' ', '\t', '\n', '\r', '\f', or '\v'. Conversion stops on the first occurrence of whitespace after one or more instances of non-whitespace or at the maximum field width, if specified. Otherwise, the array to which the input string is assigned must be large enough to hold the string plus the terminating NUL character.
The following program demonstrates this effect:
#include <stdio.h>
const int bufferSize = 80;
int main( void ) {
char stringBuffer[ bufferSize ];
printf( "Enter a string: " );
scanf("%s" , stringBuffer );
printf( "Processed...