I was wondering what is wrong with my code since it giving me a segmentation fault and I'm not sure if the problem is in how the file is being accessed or being read into the file. I'm supposed to read the file in through the command line and make sure only one file is permitted to be read. I am receiving the following error every time I try to run the program:
terminate called after throwing an instance of 'std::ios_base::failure'
what(): basic_filebuf::underflow error reading the file
I will post a portion of my code where I think the problem might be occurring.
int count = 0; // count is zero
array.user = newchar[count]; // so you are allocating an array of size 0. IE: nothing
array.role = newchar[count]; // these lines are worthless.
array.user[count] = inUser; // trying to write to array.user, but array.user is not large
// enough to hold any data. **memory corruption**
Do yourself a favor: ditch the char* nonsense and just use strings.