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.

ex:

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

1 comment:

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

 [Reference]  https://www.qnap.com/zh-tw/how-to/faq/article/%E7%82%BA%E4%BB%80%E9%BA%BC%E7%84%A1%E6%B3%95%E5%9C%A8-phpmyadmin-%E5%AD%98%E5%8...