I am trying to write some code that reads a file line by line and then outputs the text of each line using cout.
Here is what I have so far:
#include<iostream>
#include<string>
#include<fstream>
#include<sstream>
using namespace std;
int main()
{
ifstream input("test.txt");
if (input.fail())
{
cerr << "File not found!";
return -1;
}
else
{
string str;
while(getline(input,str))
{
istringstream(str);
cout << str;
cin.get();
}
return 0;
}
}
The problem I have is that it just outputs "0x22fe84" lots of times. What am I doing wrong?
Thanks,
James