Error on scanf with structure
Hi there! Wright now I am on Structures
(More Info on My Learning Diary on My Blog)
Why does the application crashes at this point? I've written the scanf form exactly like it is in the example in my book
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
Code:
struct user
{
char name, surname;
int age;
};
struct user database[10];
void read_database()
{
int i,age;
char name,surname;
for (i=1; i<2; i++)
{
printf ("\nGive name for user %d ", i);
scanf ("%s", database[i].name);
printf ("\nGive surname for user %d ", i);
scanf ("%c",database[i].surname);
printf ("\nGive age for user %d ", i);
scanf ("%d",database[i].age);
}
}
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------