I have to create a 2-Dimensional array of char pointers. The array will store a list of names and surnames - row 0 will hold names and row 1 will hold surnames. This is the code I have written so far (this file is included in the main file):
#include "myFunction.h"
#include <iostream>
#include <string.h>
using namespace std;
char ***persons;
void createArray(int n)
{
*persons = new char * int[n];
for(int i=0; i<n; i++)
*persons[i]=new char[n];
}
and main calls this function with:
createArray(3);
but when I run it i keep getting "Segmentation Fault" and I have no idea why
How can I fix this?