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

Reply via email to