/* File: scanf4.c Test use of the scanf() function to read in user input What happens if your string is too short?? */ #include main() { int n ; double x ; char name[4] ; // this string only holds 4 characters printf ("Enter an integer value for n: ") ; scanf("%d", &n) ; // don't forget the ampersand printf ("Enter a floating point value for x: ") ; scanf("%lf", &x) ; // double requires lf, not f printf ("Enter your first name (no spaces): ") ; scanf("%100s", name) ; printf ("Hello %s, you typed in %d for n and %f for x.\n", name, n, x) ; }