I've been tasked with reading in multiple emails that are stored in a single archive file and then scanning it to find certain things. My problem now is that I seem to only be reading in the first of the many individual files stored in the single archive.
The "archive" file is just plain text, nothing too special about it. I can read it in notepad.
the very last cout statement just starts printing jibberish until an illegal access is made, so i just have it print one beyond the char array bounds.
here is my code:
#include <regex>
#include <iostream>
#include <vector>
#include <fstream>
using namespace std::tr1;
using namespace std;
int main()
{
string inputfilename = "ham";
string text_file;
ifstream ifs;
ifs.open(inputfilename);
string temp;
getline(ifs, temp); // to get some initial stuff out of the way.
while(!ifs.eof())
{
getline(ifs, temp);
text_file += temp + '\n';
}
char* search = new char[text_file.size() + 1];
strcpy(search,text_file.c_str());
search[text_file.length() + 1];
int i = 0;
for(; search[i] != '\0'; i++)
cout << search[i];
cout << search[i+1];
}