Skip to content

Instantly share code, notes, and snippets.

@tjkhara
Created October 22, 2018 11:42
Show Gist options
  • Select an option

  • Save tjkhara/6bbb3702ed2019c45376a0e9f5383cce to your computer and use it in GitHub Desktop.

Select an option

Save tjkhara/6bbb3702ed2019c45376a0e9f5383cce to your computer and use it in GitHub Desktop.
2D Dynamic array of strings
/****************************************************************************
** Author: Tajeshwar Singh Khara
** Date: 25-09-2018
** Description: Function called createArray
** Creates and returns an initialized 2D array
******************************************************************************/
// Create a 2D dynamic array
string** Functions::createArray(int rowSize, int colSize)
{
// Create an array of pointers
string** arr = new string*[rowSize];
// Allocate each pointer in the array with the number of "cols"
for (int i = 0; i < rowSize; ++i) {
arr[i] = new string[colSize];
}
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment