i was just playing around with this and for some reason i can't get to work...
i have a text file (num.txt) which has ONLY 4 characters they are the following: 234'EOF'
what i'm trying to do is to read the 3 characters in untill the (end of file character) thus in result i want to add their values, however all that is being added is their ASCII representations.
I know i can use the insertion operators and input (int) integers, thus i wouldn't have a problem but i want to do it using fin.get() function...
here's the simple code:
using namespace std;
int sum = 0;
cout << "can't open the file for input\n";
cout << "ASCI : " << (int)num << endl << endl;
cout << "values : " << num << " " << endl << endl;
sum = sum + num;
cout << "The sum of 2 3 4 is: " << sum << endl;
Thanks in advance....
ps. i tried using atoi() but i just can't get it to work for some reason... it requires a (char constant) but i can't make this constant....?????