By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,377 Members | 1,658 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,377 IT Pros & Developers. It's quick & easy.

Containers & Iterators sanity check

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm using g++ 3.4.2 & am having trouble with algorithms (find) and
strings. Here's my code:

string::iterator itor = find(input.begin(), input.end(), "|");

I'm fairly sure this code worked for me in the past, as I am working out
of the same reference material I have used on previous compilers. I just
can't figure out why I am getting the following error:

/usr/lib/gcc/i386-redhat-linux/3.4.2/../../../../include/c++/3.4.2/bits/stl_algo.h:207:
error: ISO C++ forbids comparison between pointer and integer
Any help would be greatly appreciated.

Evan Carew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDsz8rpxCQXwV2bJARAuWJAKCHdbS2VQ6pBC6/cyPaTqXK6bd2KwCdE7xB
KnXpB8StjZ7CFH92Nz94Ino=
=jzu9
-----END PGP SIGNATURE-----
Dec 29 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Evan Carew wrote:
I'm using g++ 3.4.2 & am having trouble with algorithms (find) and
strings. Here's my code:

string::iterator itor = find(input.begin(), input.end(), "|");

I'm fairly sure this code worked for me in the past, as I am working out
of the same reference material I have used on previous compilers.


I'm fairly sure this code *never* worked. However, this will:

string::iterator itor = find(input.begin(), input.end(), '|');

The key difference is to pass a character rather than string literal
as the value argument.
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence
Dec 29 '05 #2

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dietmar Kuehl wrote:
Evan Carew wrote:
I'm using g++ 3.4.2 & am having trouble with algorithms (find) and
strings. Here's my code:

string::iterator itor = find(input.begin(), input.end(), "|");

I'm fairly sure this code worked for me in the past, as I am working out
of the same reference material I have used on previous compilers.

I'm fairly sure this code *never* worked. However, this will:

string::iterator itor = find(input.begin(), input.end(), '|');

The key difference is to pass a character rather than string literal
as the value argument.

Argggh! I could have looked at that code all night & not seen the double
quotes. Thanks.

Evan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDs0WFpxCQXwV2bJARAjdEAKC2k0OP/JSJCgAtZPtYzPrG65hxKACeKFeZ
nGiRmXgfap/q+PIZJczA4V0=
=S8aH
-----END PGP SIGNATURE-----
Dec 29 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.