-
i'm doin an ifstream .get() to pull in characters from a text file.
and the last character it pulls out a number. I want to return an int value.
Heres the code maybe i'm doing something wrong..
int get_version_num()
{
ifstream din;
do
{
din.get(ltr);
cout<< ltr;
if(ltr=='V')
qans++;
if(ltr=='R')
qans++;
if(ltr=='M')
qans++;
}
while(qans<4);
do
{
din.get(ltr);
i++;
}
while(i<5);
answ = ltr;
return ltr;
}
-
I can't see what you're going at with that code...what's the file it's reading from? Just a few lines is enough. But to convert a string to a number just use atoi:
Code:
int x = atoi("56");
-
Code:
#include <iostream.h>
void main()
{
char c;
c = 'A';
cout << (int)c << endl;
}