Not really interested in finishing project I am more interested in knowing why I can print the answer variable after the while loop. I know it works if I have it inside the while loop. I know I get an error code -1073741819 which meant that the loop terminate abortly or there is something wrong after the while loop ended
int main(){
int number;
int number2;
char *sign;
char *quit = {"h"};
int answer;
while (quit[0] != 'q'){
printf("Enter a num");
scanf(" %d", &number);
printf("Enter a second num");
scanf(" %d", &number2);
printf("Enter a sign");
scanf(" %c", &sign);
printf("enter a q to quit");
scanf(" %c", &quit[0]);
if (sign == "+"){
answer = number + number2;
}
}
cout << answer; //Why wont this print
cout << "Program ended";
return 0;
}