Look at your code:
char name;
...
scanf("%s", name);
You have allocated a single byte of space to hold the user's name and then read a string into it! What happens then, is that the framework obeys your command, and fills the character and the following memory with the name - which overwrites the return address on the stack for the
scanf
function call, so it tries to return to a random address and crashes.
Try declaring
name
as an array of characters:
char name[100];
...
scanf("%s", name);
And see if that works any better!