my program kept crashing for some reason and i narrowed it down to the following code (i know it has something to do with the pointer):
the cout.write function always returns a bunch of random garbage when its meant to return 'AAAAAA....', also im not 100% sure if the size im using is right.Code:
unsigned int nSize;
cTemp.nSize = 0x41414141; // set uint to 'AAAA'
cout << sizeof(_cTemp) << endl;
cTemp.sData = new char ;
memset(cTemp.sData, 'A', 100); // set char array to A's
cout << sizeof(_cTemp) + 100 << endl;
cout.write((char *)&cTemp, sizeof(_cTemp) + 100);
cout << endl;
i know the sizeof(_cTemp) = 8 (uint+pointer), when i assign the pointer 100 chars, would the size be 108? (im assuming that the size of the pointer doesnt change?).
anyway, why isnt it displaying 'AAAA..'? it shows the first 4 A's for the uint but not for the char array.