Friday, July 5, 2013

[Visual C++] Run-Time Check Failure #2 - Stack around the variable was corrupted

This run time error often happens when you try to write a string to a char[ ] whose size is smaller than the string.


char str[10];
char s10[] = "1234567890";

str[10] = 'a';         <----- error, size of str is 10, can only access str[0] ~ str[9]
strcpy( str, s10);   <----- error, size of s10 is 11, don't forget the end character '\0' or NULL

phpMyAdmin 無法存取 MariaDB 10 的解決方法