Category Archives: C++

Dynamically Creating Two-Dimensional Arrays in C++

C++ doesn’t take kindly to dynamic arrays. You can’t just plug a variable into some brackets and expect to make an array whatever size you want. There are technical reasons for this–compile time code v. run time code–but at the end of the day, it just isn’t happening.

However, it wouldn’t be a very useful language if there wasn’t some way to dynamically create arrays, so if you want to do it, you’re going to have to play with pointers. Doubly so (pun wholly and completely intended) for 2D arrays.

Read more »