VC ++ 2010 issues
Run-Time Check Failure # 2 - Stack around the variable 'x' was corrupted.
Occurs because of the string "pchar ++" (increasing the pointer value by 1), but this is also a valid operation. What to do to not give an error?
#include <iostream> using namespace std; void func(char *pchar); int main() { char *pchar, x; pchar = &x; *pchar = 'a'; func(pchar); cout << *pchar; } void func(char *pchar) { char *pch; *pchar = 'b'; pchar++; *pchar = 'c'; }
char x
. Write there 'b' is normal. Write in the next for x bytes 'c' - spoil something. vc ++ takes offense and starts to swear. - alexlz