How to initialize unsigned char pointer

Yatendra picture Yatendra · Apr 16, 2011 · Viewed 17.5k times · Source

I want to initialize an unsigned char * buffer of length 1500 so that I can store values in it from some other sources.

Answer

QuantumMechanic picture QuantumMechanic · Apr 16, 2011

If you want it on the heap,

unsigned char* buffer = new unsigned char[1500];

if you want it on the stack,

unsigned char buffer[1500];