linked-lists and displaying saved integers...

Associate
Joined
27 Dec 2004
Posts
612
Location
Andover
There is probably a simple answer to this but i'm having trouble displaying what i've input into a record (using linked lists). To start at the beginning, i'm designing a simple program that uses a single linked list (slightly pointless in my opinion but its what i'm being asked to do) that saves only 1 record...
Code:
typedef struct
{
  char name[36];
  unsigned int age[3];
  char gender[2];
  char department[20];
  char modules[10];
  unsigned int measure[2];
} Lecturer;

For example, i read in age...

Code:
printf("Age: \n");
scanf("%d", current->person.age);

But when i come to display the age again, it gives me a 6 digit number.

Code:
 printf("Age: %d \n", lecturer->person.age);

Is the number i'm seeing a memory reference? If so, how can i get it to output the right result? If not, where am i going wrong?
 
thanks for the replies guys. It was actually a mistake, a friend of mine said to use it when i originally had errors with saving to age. Everything now saves properly.

Next problem... when reading into current->person.name it doesn't like spaces and causes the rest of the record to skip. E.g:
Name: Bob Timpson
Age: <skips>
Gender: <skips>
Department: ....
etc

Is there something wrong with my record or is it just C being a bit silly?
 
How do i stop it begin a delimiter? For a quick fix i've just made first name and second name and when you put a space inbetween it reads to each pointer.
 
Back
Top Bottom