Trying to text from text file, getting weird characters
No matter whate i try, text or string, I am getting weird characters from the file....all the file has is 101.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
infile.open("test.txt", ifstream::in);
infile.unsetf(ios_base::skipws);
if(infile.is_open())
{
string content;
char prevCont;
if(infile.good())
{
while(!infile.eof())
{
infile>>prevCont;
content += prevCont;
}
}
else
{
cout << "Error opening file." << endl;
}
infile.close();
//contents.erase(contents.size()-1);
for(unsigned int i = 0; i < content.size(); i++)
{
cout << content[i] << endl;
cin>>new char;
}
|
I have tried many things, from the internet. I just need a simple solution that allow me get each character from the text in the file.
Topic archived. No new replies allowed.