I am writing this code to allow user to play game "Guess the number". Once the user guesses right number it asks user if he/she wants to play again. This code works for two plays and if user inputs 'y' to play again for third time, the code shows exception. The exception details are:"Unhandled exception at 0xFEFEFEFE in Ex 5.32 Guess the number.exe: 0xC00001A5: An invalid exception handler routine has been detected (parameters: 0x00000003)."
#include "stdafx.h"
#include <math.h>
#include <stdlib.h>
int a = 1;
int main(int g){
int num, guess;
char YesOrNo;
srand(g);
num = 1 + rand() % 1000;
printf("I have a number between 1 and 1000\nCan you gess my number?\n");
do{
scanf_s("%d", &guess);
if (guess == num){
printf("Excellent! You guessed the number!\n");
break;
}
else if (guess < num)
printf("Too low. Try Again.\n");
else
printf("Too High. Try Again.\n");
} while (1);
printf("Would you like to play again(y or n) ? ");
scanf_s("%s", &YesOrNo);
if (YesOrNo == 'Y' || 'y'){
a++;
main(a);
}
else{
return 0;}
}