944,021 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1214
  • C++ RSS
Aug 3rd, 2005
0

neef u help

Expand Post »
#include<iostream>
#include<string>
using namespace std;
void main()
{
string str="hello world";
string::const_iterator p=str.begin();
while(p!=str.end())
{
cout<<*P<<endl;
p++;
}
}
when i try to run this program.it doesn't working.
it tells me the 'p' is not declared identifier.

string::const_iterator p//the defination is wrong?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wu7jian is offline Offline
18 posts
since Jul 2005
Aug 3rd, 2005
0

Re: neef u help

You capitalized P in the cout but it was lower case p before.

(Also, main is supposed to return int, but that's an unrelated problem)
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005
Aug 3rd, 2005
0

Re: neef u help

>it tells me the 'p' is not declared identifier
No, it tells you that P is not a declared identifier. Notice the difference in case and remember that C++ is case sensitive.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Aug 3rd, 2005
0

Re: neef u help

winbatch and narue.
both of you.
thank you very much.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wu7jian is offline Offline
18 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: building my first MFC Program
Next Thread in C++ Forum Timeline: Please I need help formatting an output file and sorting the names!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC