From: "learning c++" <learning_c@hotmail.com>
To: gcc-help@gcc.gnu.org
Subject: for argument `1' to `int strcmp(const char*, const char*)
Date: Wed, 01 Sep 2004 14:20:00 -0000 [thread overview]
Message-ID: <BAY12-F188wx6EWQyNk00012fac@hotmail.com> (raw)
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
next reply other threads:[~2004-09-01 14:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-01 14:20 learning c++ [this message]
2004-09-01 16:44 lrtaylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BAY12-F188wx6EWQyNk00012fac@hotmail.com \
--to=learning_c@hotmail.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).