473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Containers & Iterators sanity check

-----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
2 1484
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
-----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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ney André de Mello Zunino | last post by:
Hello. A non-modifying algorithm I implemented uses two associative containers from STL: set and map. The elements on those containers are supposed to refer to actual elements which lie on...
4
by: Merlin | last post by:
Hi, I am a C++ developer and would like to implement container classes for various types of objects. I use MS Visual C++ to compile my code. Nevertheless I like to write code that is independent...
8
by: Gregory | last post by:
I have a question about using STL containers in C++ class public interface. Lets say that I want to return some container from class method or accept class method parameter as some container. For...
2
by: bob | last post by:
Hi, Given: 1) Custom containers that have nothing to do with vector, deque, list, map etc, 2) a custom version of new and delete defined for these containers, customNew and customDelete,...
9
by: nicolas.michel.lava | last post by:
Hi there, I have some trouble using STL containers. I'm working on a multithreaded (pthread) application making heavy usage of STL containers. All accesses to containers are made in locked...
23
by: Sanjay Kumar | last post by:
Folks, I am getting back into C++ after a long time and I have this simple question: How do pyou ass a STL container like say a vector or a map (to and from a function) ? function: ...
1
by: yonil | last post by:
I hope this is the correct group for this... I'm currently implementing the TR1 associative containers according to specification found in...
21
by: George Exarchakos | last post by:
Hi everyone, I'd like your help... Can we have a std::list<BASEwhere BASE be the base class of a class hierarchy? I want to add to this list objects that are inherited from BASE class but not...
3
by: subramanian100in | last post by:
I am copying the following lines as it is, from Stanley Lippman's C++ Primer 4th edition, page 418(First paragraph). It says: "Although the map and set types provide bidirectional iterators, we...
3
by: zr | last post by:
Hi, Does usage of checked iterators and checked containers make code more secure? If so, can that code considered to be reasonably secure?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.