How are you reading in "John Smith" from the user? I bet you're using something like this:
scanf("%s") only reads until the first whitespace character. That is, "John" will be stored in name, and "Smith" will remain in the input stream. This could cause a problem if, for example, you read John Smith's age right afterwards; scanf() will see "Smith" and conclude that that isn't a number (which it isn't), and return an error code (which you probably don't check for), leaving the age variable unchanged.
To read spaces into name, use fgets() instead of scanf().
http://faq.cprogramming.com/cgi-bin/...&id=1043284385
Code:
#include <stdio.h> /* for BUFSIZ and fgets() */
#include <string.h> /* for strchr() */
char name[BUFSIZ], *p;
fgets(name, sizeof(name), stdin);
if((p = strchr(name, '\n')) != 0) *p = 0; /* remove the newline from name */
When reading numbers from the user, you could discard non-digit input, or use fgets() to read the line and sscanf() to parse it, or something of the like.
http://faq.cprogramming.com/cgi-bin/...&id=1043284385