Store not arrays of chars buffer in the vector, but the pointers to the buffer
Code:
std::vector<char*> instructions;
.
.
.
char buffer[200];
.
.
.
instructions.pushback(&buffer);
This will work great now. One little problem though. You will overwrite your data everytime you read a new line. Do this:
Code:
std::vector<char*> instructions;
char *szBuffer;
while (! jppfile.eof() ) {
szBuffer = new char[201]; // 201?? make room for 200 chars and the ending '\0'
memset(szBuffer, 0, 201); // clear the buffer
jppfile.getline (szBuffer, 200);
cout << szBuffer;
instructions.push_back(szBuffer); //szBuffer is a pointer!
}
// do this when you no longer need the instructions:
std::vector<char*>::iterator it;
for(it = instructions.begin(); it != instructions.end(); it++){
delete *it;
}
or something...