TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JACK EVERETT
from: JERRY COFFIN
date: 1997-10-17 15:37:00
subject: Sequential files

On (11 Oct 97) Jack Everett wrote to All...
 JE> I have a sequential file that I have created...but I would like to
 JE> read in the file then break down each line into variable..is this
 JE> possible or do I need to go Random file...
As far as C++ cares, there's no such thing as a file being random or
sequential - there are just files, and you can access any of them
randomly or sequentially.
In this case, you'd do something like this:
string lines[max_lines];
    ifstream input("input_file.txt");
    for ( int i=0; i < max_lines && !input.bad(); i++)
        input >> lines[i];
Depending upon how new it is, your compiler may not support the `string'
data type, in which case you'll have to read your lines into buffers of
characters.
    Later,
    Jerry.
--- PPoint 2.02
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.