मैं एक स्ट्रिंग में "_" के पदों जानना चाहता हूँ:मैं सी ++ स्ट्रिंग में "_" का पता कैसे लगा सकता हूं?
string str("BLA_BLABLA_BLA.txt");
कुछ की तरह:
string::iterator it;
for (it=str.begin() ; it < str.end(); it++){
if (*it == "_") //this goes wrong: pointer and integer comparison
{
pos(1) = it;
}
cout << *it << endl;
}
धन्यवाद, आन्द्रे
डबल कोट्स के बजाय सिंगल कोट्स का उपयोग करने का प्रयास करें। –
@ डोमिनिक यह जवाब क्यों नहीं है? – Motti
@ मोट्टी - अब यह है (एसबीआई का जवाब देखें http://stackoverflow.com/questions/3725574/detect-in-a-string/3725671#3725671) –