Re: c++ string stuff

From: MrPlow (desolate19_at_hotmail.com)
Date: 02/24/04


Date: Tue, 24 Feb 2004 03:42:01 GMT

Chris ( Val ) wrote:
<snip>
>
> There are ways :-).
>
> # include <iostream>
> # include <fstream>
> # include <ostream>
> # include <string>
>
> int main()
> {
> std::ifstream fuser( "Test.txt" );
>
> std::string fline;
> std::string::size_type Pos( 0 );
>
> while( std::getline( fuser, fline ) && fuser >> std::ws )
> if( ( Pos = fline.find_first_of( ':' ) ) != std::string::npos )
> std::cout << fline.substr( 0, Pos ) << std::endl;
>
> return 0;
> }
>
> Cheers.
> Chris Val
>
>

Thanks everyone for the helpful replies. This example comes the closest
to what I was wanting :) I think my problem was that in trying to get
rid of C strings, I was throwing out all techniques for working with
strings too and thinking that I should do everything with iostream type
stuff. I'll only have to change this slightly since I can't assume that
there won't be a ':' in a comment line.

Thanks again