|
-
Mar 7th, 2001, 11:50 AM
#1
Thread Starter
Member
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;
}
Last edited by Flamer; Mar 7th, 2001 at 12:11 PM.
-
Mar 7th, 2001, 01:04 PM
#2
Monday Morning Lunatic
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");
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Mar 7th, 2001, 02:29 PM
#3
Addicted Member
Code:
#include <iostream.h>
void main()
{
char c;
c = 'A';
cout << (int)c << endl;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|