Reputation: 1279
My code is like below:
#include <string.h>
int main()
{
int ii = 123;
char str[7] = "";
strcpy(str,"123456");
return 0;
}
I run this in VS2010, the memory is like below
I am curious what the cc
in the memory used for? And how the number of cc
is calculated?
Upvotes: 5
Views: 289
Reputation: 80
When you access the uninitialised memory space, VC2010 will always warn you that you have accessed some address containing 0xcccccccc
,
0xcc
is the value used by the compiler (in a debug build) to fill up the uninitialized memory.
Upvotes: 1
Reputation: 471199
When compile for "Debug" in Visual Studio, the cc
's are often used to fill up uninitialized memory. That way it's more obvious when you access uninitialized memory.
For example, if you try to dereference an uninitialized pointer, you'll likely get something like:
Access Violation accessing 0xcccccccc
or something like that.
Upvotes: 7