Hi, I am trying to read each character from a file in c++, also,I need to get their ascii value, but I have a problem on the output, there are two characters else I dont need, even I donĀ“t why they appear.
Here is the code and the output, thanks a lot.
#include <iostream>
#include<fstream>
using namespace std;
int main()
{
ofstream wfile("Ej_01.txt");
wfile<<"AbCd"<<endl;
wfile.close();
ifstream lfile;
lfile.open("Ej_01.txt");
char word;
int temp;
while(lfile.good()){
lfile.get(word);
temp=word;
cout<<word<<" "<<temp<<endl;
}
cout<<endl;
lfile.close();
return 0;
}
And this is the output:
A 65
b 98
C 67
d 100
10
10
Press <RETURN> to close this window...
So How can I get the same result without de last two '10'??