To read in more than a single character requires the scanf() function. This function reads what has been typed into the keyboard and converts it to a particular data type, based on the formatting code given to it (just as the printf() function prints values based on formatting codes).
To use this function to read in a word, you must first define a character string, which was also briefly mentioned in Chapter 2. For example:
This creates a character string called word that can be up to 20 characters in length.
Next, you would prompt the user and tell the scanf() function what type of data to expect and to which variable that data should be assigned:
printf ("Please enter a word: "); scanf ("%s", word); ...