Search code examples
c++cpointerscharunsigned-char

How to initialize unsigned char pointer


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


Solution

  • 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];