#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?

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)

>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.

winbatch and narue.
both of you.
thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.