c++ work around comparison between pointer and integer -
do { getline (myfile,temp); if (temp[0] != "="){ myalbums[i].tracks.push_back(temp); } else { break; } }while(true);
gives me error:
iso c++ forbids comparison between pointer , integer [-fpermissive]
i trying loop through lines in text file , 'push_pack' if line not begin "=" equals character. else want break out of loop.
any appriceated!
if (temp[0] != "="){
should be
if (temp[0] != '='){
the reason temp[0]
of type char
(assume temp
string read in), should compare char literal '='
not string literal "="
. assuming read temp
successfully, may need check if not case.
edit(thanks adam liss)
strings literals "="
of (const char *
) type, enclosed in double-quotes; individual characters enclosed in single-quotes. therefore, have compile complain message comparing char
(char literal integers) const char *
.
quoting here:ibm c++ documentation
c character literal has type int. c++ character literal contains 1 character has type char, integral type.
Comments
Post a Comment