Solution for Exercise 7-12

ex0712

#include <stdio.h>

int main()
{
    char firstname[15];

    printf("Type your first name: ");
    scanf("%s",firstname);
    printf("Pleased to meet you, %s.\n",firstname);
    return(0);
}

Output

Type your first name: Danny
Please to meet you, Danny.

Notes

* The text input above is the string Danny.

* The string buffer has storage for up to 15 characters, created at Line 5. This value is just a guess.

* The scanf() function reads in text up to the first white space character. If you type Billy Bob as your first name, input after the space is ignored, and the output shows only the text Billy.