I just started my C language and I came to this error. I tried to look up online but other threads contain ARRAY which I am not familiarize with.
#include<stdio.h>
int main(void){
char input;
printf("ASCII testing\n");
scanf( "%d", &input); //the error occurs here but would like to know the solution
printf("answer is : %c\n" , input);
system("pause");
return 0;
}
“Run-Time Check Failure #2 – Stack around the variable ‘input’ was corrupted.”
Simple point-out will be much appreciated
//Edited
Well I would like to enter value “66” so that the outcome would be B. The scanf(“%c , &input) accepts 1 keystroke from the keyboard so that’s not what I am looking for. But nevertheless, thank you for the replies
The
%dformat specifier inscanf()requires a pointer to anintvariable, not a pointer to achar. Try: