ex24 extra credit
This commit is contained in:
parent
1f288ddd5b
commit
b12812b91c
@ -24,18 +24,25 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Person you = {.age = 0};
|
||||
int i = 0;
|
||||
int rc = -1;
|
||||
char *in = NULL;
|
||||
|
||||
printf("What's your First Name? ");
|
||||
in = fgets(you.first_name, MAX_DATA-1, stdin);
|
||||
check(in != NULL, "Failed to read first name.");
|
||||
|
||||
rc = sscanf(you.first_name, "%s", you.first_name);
|
||||
check(rc > 0, "Failed to strip first name.");
|
||||
|
||||
printf("What's your Last Name? ");
|
||||
in = fgets(you.last_name, MAX_DATA-1, stdin);
|
||||
check(in != NULL, "Failed to read last name.");
|
||||
|
||||
rc = sscanf(you.last_name, "%s", you.last_name);
|
||||
check(rc > 0, "Failed to strip last name.");
|
||||
|
||||
printf("How old are you? ");
|
||||
int rc = fscanf(stdin, "%d", &you.age);
|
||||
rc = fscanf(stdin, "%d", &you.age);
|
||||
check(rc > 0, "You have to enter a number.");
|
||||
|
||||
printf("What color are your eyes:\n");
|
||||
@ -57,8 +64,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("----- RESULTS -----\n");
|
||||
|
||||
printf("First Name: %s", you.first_name);
|
||||
printf("Last Name: %s", you.last_name);
|
||||
printf("First Name: %s\n", you.first_name);
|
||||
printf("Last Name: %s\n", you.last_name);
|
||||
printf("Age: %d\n", you.age);
|
||||
printf("Eyes: %s\n", EYE_COLOR_NAMES[you.eyes]);
|
||||
printf("Income: %f\n", you.income);
|
||||
|
Loading…
Reference in New Issue
Block a user