问题
Possible Duplicate:
Correct way to use scanf / printf (and family) with fixed size types?
I have written the following program in Visual Studio:
Upon running the program and exiting, I get the error message "stack around variable b was corrupted". If I replace _int 16 with int, no exception is raised. How can I solve this problem please? I have to use _int16 since I want to simulate an integer overflow. Thanks :)
回答1:
As pointed out in the comments, the solution is to replace
scanf("%d", &a);
with
scanf("%hd", &a);
来源:https://stackoverflow.com/questions/12936521/c-exception-when-using-int16