I'm having Process returned - 1073741819 (0xC0000005) error in C Program

-1

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);
}
c
asked on Stack Overflow Apr 10, 2020 by Sayuru Akash • edited Apr 10, 2020 by Barmar

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0