Created
October 22, 2018 11:42
-
-
Save tjkhara/6bbb3702ed2019c45376a0e9f5383cce to your computer and use it in GitHub Desktop.
2D Dynamic array of strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /**************************************************************************** | |
| ** 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