I need help understanding this error message

+3 Eric Hines · January 8, 2016
Process terminated with status -1073741510 (0 minute(s), 10 second(s))

I've been practicing some basic tutorials and this error message comes up after I attempt to build and run. Here is my code.

#include <stdio.h>
#include <stdlib.h>

int main()
int currentyear;
int birthyear;
int age;
age = currentyear-birthyear;

printf("when were you born? \n");
scanf(" %d", &birthyear);

printf("what year is it? \n");
scanf(" %d", &currentyear);

printf("you are %d years old", age);

return 0;

Post a Reply


Oldest  Newest  Rating
0 first last · January 8, 2016
rewatch the C videos 

you can't do this 
age = currentyear-birthyear; 

at that point in the code 

neither curretnyear nor birthyear have a value at that point  

when you write a program think about the code logically  
think about each line step by step  

if you met a stranger could you figure out their age by subtracting the birthyear from the currentyear when you haven't even yet asked them what their birthyear is ?
0 Eric Hines · January 9, 2016
I suppose I don't understand. 
The purpose was for the program to read the user's input with scanf after each prompt. 
So does this still not set the variable's value and therefore it would be able to just make the calculation?

I wanted the program to run as if you are having a conversation with a stranger in a sense. 
0 Eric Hines · January 9, 2016
I'm also trying to come up with a program to test my if/else understanding. 

this is what I'm thinking for an arduino project. nothing elaborate, but simple and easy to see results;

if(receive user input)

(blink an LED)

else(receive user input)
(stop blinking LED)

I'd want the LED to blink indefinitely and therefor I think it should be a loop function, but I'm not certain which kind. 

I'm not sure if I'm on the right track or not. 
0 Stevan Zečević · January 9, 2016
You get error because the compiler works line by line from top to bottom so you need to set value of  currentyear and birthyear first then calculate age hope i helped
0 Eric Hines · January 11, 2016
Thanks. I did figure it out. 
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator