Hello, wondering if someone can help me quickly..
Basically, I have created a array to store all the data in a text file. The pointer of the array is sent to a function, which then populates it. Here is the code:
void Data(char* theData)
{
ifstream txtFile(inputFile.c_str());
if(!txtFile.is_open())
{
cerr << "Cannot open text file";
}
char getData[100000];
txtFile.read(getData, sizeof getData);
theData = getData;
}
int main(int argc, char *argv[]) {
char* data;
Data(data);
cout << data[0];
}
I get a segmentation fault, and I think it's to do with how I'm copying getData into theData.
Could anyone help ?
Thanks