this question has answer here:
- c++ string equivalent strrchr 4 answers
#include <iostream> #include <string> #include <cstring> using namespace std; int main(){ string a="asdasd"; if(!strchr(a,'a')) cout<<"yes"; return 0; } i began learn c++ programming , don't know why got error in line
if(!strchr(a,'a')) cout<<"yes"; but if tried code this, run well.
if(!strchr("asdasd",'a')) cout<<"yes"; i know stupid question don't know why.. sorry..
the library function strchr use c-style strings, not c++ string type.
Comments
Post a Comment