I am doing testing and below is a piece of code that is giving me an error : Unhandled exception at 0x00956faa in myprogram.exe: 0xC0000005: Access violation reading location 0xcccccccc.
The function is:
ECommand(unsigned char CBuffer[], const CDBuffer_t * const SdBuffer_Ptr)
The piece of code:
unsigned char CBuffer[11];
memset(CBuffer,0,sizeof(uint8_t)*4);
CBuffer[2] = 0x02;
CDBuffer_t sendBuffer;
sdBuffer.buffer = static_cast<uint8_t *>(malloc(sizeof(uint8_t)*8));
memset(sdBuffer.buffer,0,sizeof(uint8_t)*8);
CBuffer[6] = 0x02;
ECommand(CBuffer,&sdBuffer);
getting error at:
ECommand(CBuffer,&sdBuffer);
Also
typedef struct CDBuffer_t
{
uint8_t *buffer;
uint16_t count;
uint16_t size;
uint16_t status;
} CDBuffer_t;
If any more info is required let me know. I know its something to do with memory accessing but am not able to figure it out please help me get rid of the program crashing because of above exception Thanks