At 09:02 2007-03-29, akhila_3 wrote: >Well >"while (getline (ifs, tmp))" >does not work. i cant use a file ifs.. i have to use a string... >i got an error saying it was not a valid expression.. >is there an alternative way of doing this?
the SUBJECT of this is "file handling in C++" so...why can't you use a file??? >Thanks > > > > >--- In [email protected], "Tamas Marki" <[EMAIL PROTECTED]> wrote: > > > > On 3/29/07, akhila_3 <[EMAIL PROTECTED]> wrote: > > > the line i am trying to read looks something like this: > > > cfg.?.readline=("string1,string2"); > > > > > > there are a 1000 lines in the file that begin with cfg but only >1 that > > > has "readline" in it. also i dont know wat variable1 and >variable2 are > > > (there could be more than 2 strings. i am not supposed to know >the > > > count either). i have to read them in and print them out. > > > > > > the other thing is the config file is located in another dir. > > > > > > Can you please tell me how i can extract the line from the config > > > file. i was thinking of using fgets... but was not sure if C++ >had a > > > better way of doing this? > > > n also how exactly does getline work? > > > > Real simple. Consider (untested, simplified, but should work): > > > > ifstream ifs ("/path/to/filename"); > > string tmp; > > while (getline (ifs, tmp)) > > { > > cout << tmp << endl; // echo line or process it > > } > > > > > > -- > > Tamas Marki > > > > > > >To unsubscribe, send a blank message to ><mailto:[EMAIL PROTECTED]>. >Yahoo! Groups Links > > > Victor A. Wagner Jr. http://rudbek.com The five most dangerous words in the English language: "There oughta be a law"
