c++ bad_alloc error with file storage
c++ bad_alloc error with file storage So, my exercise is to read three files and write them in a new one. My first thoughts were to put the files in a vector and then write the vector in the new file. int main(int argc, char* argv){ vector<string> book; ifstream input1; input1.open(argv[1]); string line; while(!input1.eof()) { getline(input1, line); book.push_back(line); } ofstream output; output.open(argv[4]); unsigned int n = book.size(); for(unsigned int i = 0; i < n; i++) { output << book[i]; } This is a part of it. I read similar questions and they all were about items. How will i fix this problem with file rows of strings? Checking argc might be an idea if (argc < 5) return -1; – Surt Jun 30 at 15:58 By clicking "Post Your Answer...