Is there a way to get the contents of a file and place it into a string?
So far I have the following:
Code:
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;
int main()
{
ifstream file;
string word;
int count;
map<string, int> table;
file.open("main.cpp");
if(!file)
{
return 1;
}
word = "#include";
system("PAUSE");
return EXIT_SUCCESS;
}
I've tried setting word = file, doing a while(file>>word), and some other things (such as setting word = file.open(), file.count, and things that generally didn't work).
Is there a way to set the contents from that file into the string for manipulation?