Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-30-2004, 12:28 AM   #1
Registered: Mar 2004
Posts: 79

Rep: Reputation: 15
Post Problem in Iterator- g++

Hi all
following piece of code is giving compilation error under g++

using namespace std;
int main()
string s("Ashwini");
char *itr= s.begin();
return 0;

g++ is giving the following error message

cannot convert `__gnu_cxx::__normal_iterator<char*,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > >' to
`char*' in assignment

If anyone has some idea then please help.
Thanx in advance
Old 04-30-2004, 01:08 AM   #2
Registered: Mar 2004
Posts: 79

Original Poster
Rep: Reputation: 15
I found the solution :- Such kinf of pointers type casting wont work under g++ unlike Visual C++ compiler, so we have to take string::iterator instead of char *.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert between list<T>::iterator and T* shreks Programming 2 08-26-2004 06:27 PM
Stl iterator woes Config Programming 4 06-23-2004 06:31 PM
compile error while returning STL iterator as object * rameshmiraje Programming 2 06-20-2004 02:50 PM
error in assigning the iterator to refrence varaible ashwinipahuja Programming 1 06-18-2004 06:55 AM
_gnu Iterator Error-g++ ashwinipahuja Programming 4 05-27-2004 12:17 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:52 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration