I am very new to C++, and for a project I am working on, I am trying to initialize a char array buffer with the following code:
const int nodeCount = pList->getNumNodes();
const size_t bufferSize = sizeof(Node) * nodeCount;
char buffer[bufferSize];
and gets an error saying the size must be constant. I understand that this is because the compiler needs to know the size at compile time. But the size of the buffer in this case depends on the number of nodes in the list, which I have no way of knowing beforehand. How can I get around this restriction? Any help is appreciated, thank you.
I should add that this is for school and the professor does not allow STLs.