Re: Text File parsing
From: Gernot Frisch (Me_at_Privacy.net)
Date: 08/11/04
- Next message: Gianni Mariani: "Re: passing const ptr argument"
- Previous message: Ioannis Vranos: "Re: Garbage Collection - Stop Making Trash"
- In reply to: Imran: "Text File parsing"
- Next in thread: Karl Heinz Buchegger: "Re: Text File parsing"
- Reply: Karl Heinz Buchegger: "Re: Text File parsing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 11 Aug 2004 10:30:49 +0200
"Imran" <imran.ar@in.bosch.com> schrieb im Newsbeitrag
news:cfckk8$kse$1@ns1.fe.internet.bosch.com...
>
>
> hello all, I have to parse a text file and get some value in that.
>
> text file content is as follows.
>
> ####TEXT FILE CONTENT STARTS HERE #####
> /start
> first
> 0x1234
> AC
> /end
>
> /start
> first
> 0x12345
> AC
> /end
>
> /start
> first
> 0x12344
> AC
> /end
>
> someotherdatahere
> ####TEXT FILE CONTENT ENDSHERE #####
>
> If user gives "first" to my program, I have to give him 0x1234. So
my doubt
> is, how can I parse text files in C++.
>
> And in text file, I have to serach in /start and /end block.
> Thanks in Adv
ifstream is("filename.txt"); // open a file stream
string line; // S string for a line to read
while(is.good()) // As long as there's data
{
is >> line; // read a line
cout << line << endl; // output it
}
- Next message: Gianni Mariani: "Re: passing const ptr argument"
- Previous message: Ioannis Vranos: "Re: Garbage Collection - Stop Making Trash"
- In reply to: Imran: "Text File parsing"
- Next in thread: Karl Heinz Buchegger: "Re: Text File parsing"
- Reply: Karl Heinz Buchegger: "Re: Text File parsing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]