for argument `1' to `int strcmp(const char*, const char*)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I hope to use the build in function ""strcmp()" in C++, but I can not deal with it. My code is like this:


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
using namespace std;

int main(){
vector<string> v1;
vector<string>::iterator iter;
string s;
do{
cout <<"please input something:" <<endl;
cin>>s;
v1.push_back(s);
}while (!(strcmp(s,"quit")));

for(iter=v1.begin(); iter!=v1.end();iter++)
cout <<*iter<<endl;

return 0;
}

error: cannot convert `__gnu_cxx::__normal_iterator<char*,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > >' to
`const char*' for argument `1' to `int strcmp(const char*, const char*)'


I know now "s" is an object of string. How can I compare it with a string, like ""quit"? Are there some methods in String class?

Thanks,

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux