Ok so I scraped the other code and started over and I still can't get this. I'm sorry for all the obvious errors I might be making I'm just trying to go by the book but I'm not getting these parts that I am messing up. Here is the new code I created:
Code:
/* This program is designed to produce a Name, Date of Birth and a SS number */
#include <stdio.h>
/* Desfine Variables */
char first_name; /* First Name of User */
char middle_name; /* Middle Name of User */
char last_name; /* Last Name of User */
int year_born; /* Birth Date */
int current_year; /* Current Year */
int age; /* Age to Date */
int ssn_1; /* First three numbers of your SS */
int ssn_2; /* Middle two numbers of your SS */
int ssn_3; /* Last four numbers of your SS */
int main()
{
year_born = 1983;
current_year = 2012;
age = current_year - year_born;
first_name = John;
middle_name = W;
last_name = Doe;
ssn_1 = 045;
ssn_2 = 68;
ssn_3 = 3257;
printf("Hello, my name is %s\n%s\n%s", first_name,middle_name,last_name);
printf("This year I'm going to %d years old", age);
printf("My SS number is %d\n%d\n%d\n", ssn_1,ssn_2,ssn_3);
return(0);
}
Now I get the following error:
Code:
Manuel-Velezs-MacBook-Pro:c_files Manolo$ cc -g -o exercise_1 exercise_1.c
exercise_1.c: In function ‘main’:
exercise_1.c:22: error: ‘John’ undeclared (first use in this function)
exercise_1.c:22: error: (Each undeclared identifier is reported only once
exercise_1.c:22: error: for each function it appears in.)
exercise_1.c:23: error: ‘W’ undeclared (first use in this function)
exercise_1.c:24: error: ‘Doe’ undeclared (first use in this function)
exercise_1.c:29: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’
exercise_1.c:29: warning: format ‘%s’ expects type ‘char *’, but argument 3 has type ‘int’
exercise_1.c:29: warning: format ‘%s’ expects type ‘char *’, but argument 4 has type ‘int’
exercise_1.c:29: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’
exercise_1.c:29: warning: format ‘%s’ expects type ‘char *’, but argument 3 has type ‘int’
exercise_1.c:29: warning: format ‘%s’ expects type ‘char *’, but argument 4 has type ‘int’
I thought by maybe changing the variables around it might work but I guess I'm using them wrong.