I don't know what process are you using to get input from the file. So I am going to describe the easiest. freopen . To open a file using freopen you just type
freopen("a.txt","r",stdin);
at the begining of the main function. Every thing after this would be like you are taking input from console.
Now about your string. I don't know if you want to save the words in a space separated string or not, I assume you want that. Here is an example code
string main_string;
string temporary_string; // word read in each attempt;
while(cin>>temporary_string)
{
main_string = main_string +" "+temporary_string;
}
this code will read until the end of file. You can also use the append function