Victor Bazarov <> wrote in
news:_Dmnf.57118$ o.verio.net:
> sd2004 wrote:
[snip]
>>
>> istream& operator>>(istream& is, astruct& s){
>> // Just want to skip line with #
>> if(is.find("#")!=string::npos) continue; // this cause the
>> progam
>> NOT compile.
>
> You're trying to use a non-existent function "find" on the 'is'
> object. The class 'istream' does NOT have a 'find' member. Perhaps
> you should use some other way of determining that the line you're
> reading starts with a pound character...
>
....perhaps by reading each line from the istream into a std::string
std::string DOES have a find() member.
istream& operator>>(istream& is, astruct& s)
{
std::string line;
while( std::getline( is, line ) )
{
if( line.find('#') == std::string::npos )
{
// no '#', create an in-memory stream and read it
std::istringstream mem_strm( line );
mem_strm >>s.skip>>s.name >> s.id >>s.loan >> s.interest_rate;
}
}
}
--
Life is complex, with real and imaginary parts.
|