>this is all ive got
I suppose it
could be worse.
>cout<<enter massage"<<endl;
You forgot the opening double quote for the string. This will cause your code to fail compilation.
>cin.ignore();
There's exactly no point to this line. In fact, it'll probably surprise users.
>int z=msg.length();
Type mismatch. length returns an unsigned quantity, the type of which can be acquired by saying
string::size_type instead of int.
>fo(int n=z;n>-1;n--)
"fo", huh? I don't recall that on the list of C++ keywords. You also have an off-by-one error where you access
msg[msg.length()] . Indexing in C++ is zero-based, so you're accessing the string beyond the last character.
In the interests of helping you improve, I'll teach you a trick for using unsigned types in a loop that counts down to zero. It's helpful in cases like this where you need to stop after zero, but can't actually get below zero. The trick is to rely on unsigned wraparound:
string::size_type n = msg.length();
while ( --n != (string::size_type)-1 )
cout<< msg[n];
When you cast -1 to an unsigned type, you get the largest value of that unsigned type. This has the same effect as decrementing an unsigned type with a value of zero.