C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

reading from files with fstream

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
nadz
Guest





PostPosted: Sun Sep 28, 2003 8:45 pm    Post subject: reading from files with fstream Reply with quote



Here is the problem I am having. Right now i need to open a file and read
from it using fstream. I can do that. However, the file I am reading from
consists of two numbers at that top and then a series of other characters.
The other characters I can do with no problem however, I do not know how to
read the numbers as ints. I want to send them to integer variables. I have
been using the get(<variable name>) to extract the characters with no
problem. If somebody could help me I would be most appreciative. Thanks in
advance!!!


~Justin


Back to top
Mike Wahler
Guest





PostPosted: Sun Sep 28, 2003 8:54 pm    Post subject: Re: reading from files with fstream Reply with quote



"nadz" <jnadz (AT) lsol (DOT) net> wrote

Quote:
Here is the problem I am having. Right now i need to open a file and read
from it using fstream. I can do that. However, the file I am reading
from
consists of two numbers at that top and then a series of other characters.
The other characters I can do with no problem however, I do not know how
to
read the numbers as ints. I want to send them to integer variables. I
have
been using the get(<variable name>) to extract the characters with no
problem. If somebody could help me I would be most appreciative. Thanks
in
advance!!!


stream >> number;

It's much easier to help if you post your code.

-Mike



Back to top
Kevin Goodsell
Guest





PostPosted: Sun Sep 28, 2003 9:06 pm    Post subject: Re: reading from files with fstream Reply with quote



nadz wrote:
Quote:
Here is the problem I am having. Right now i need to open a file and read
from it using fstream. I can do that. However, the file I am reading from
consists of two numbers at that top and then a series of other characters.
The other characters I can do with no problem however, I do not know how to
read the numbers as ints. I want to send them to integer variables. I have
been using the get(<variable name>) to extract the characters with no
problem. If somebody could help me I would be most appreciative. Thanks in
advance!!!

It depends heavily on your file format, but in many cases you can just
do this:

ifstream_var >> int_var;

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.