I am a beginner to C and I wrote this code to display name and age after someone enter name and birth year. I'm using codeblocks. When i run this program crashes and it gives me "Process returned - 1073741819 (0xC0000005)" error after I run the program and enter name. Can someone please tell me the issue with my code and help me fix it. Thanks
This is the code:
#include <stdio.h>
int main()
{
char studentname;
int birthyear, currentyear=2020, age;
printf ("Input your Name: ");
scanf ("%s", studentname);
printf ("Input your birth year: ");
scanf ("%d", &birthyear);
age= currentyear - birthyear;
printf ("Name of the Student: %s\n", studentname);
printf ("Age of the student: %d\n", age);
}
User contributions licensed under CC BY-SA 3.0