I am working on a small homework program with C, and I encountered a very unusual issue. I was coding this in C using Visual Studio 2012. The program compiles without errors, and it also runs in cmd until a certain stage where it crashes with an exception. Please ignore the logic of the program, I cut some parts to focus on the error itself. I would really appreciate some help on this. Thank You!
Here is the program:
#include <stdio.h>
#include <math.h>
int main( void )
{
int menuinput;
int austinHour, austinMinute;
int irishHour, irishMinute;
printf("Insert a Number from 1-11 to select menu option: ");
scanf_s("%d",&menuinput);
switch(menuinput)
{
case 1:
{
irishHour=0;
irishMinute=0;
austinHour=0;
austinMinute =0;
printf("Enter Austin time: ");
scanf_s("%d %d",austinHour,austinMinute);
irishHour = (austinHour + 61);
printf("%d %d",irishHour, austinMinute);
}
}
The error is the following when I try to run the program:
First-chance exception at 0x62ACD745 (msvcr110d.dll) in Lab2.exe: 0xC0000005: Access violation writing location 0x00000000.
If there is a handler for this exception, the program may be safely continued.
You have an typo, You did not pass the address of arguments in
scanf:And I say it is an typo because you did so correctly the fist time you use scanf: