Hi....

Can anyone help?

char message[] = "This is a message.";
Write C++ code to print the string out backwards.

Thanks.

Recommended Answers

All 3 Replies

Yes. See
this

recursion will work, providing the message isn't too long.

Well, you can use

int y;  //counters
string message="hello world";  //string to hold message

for(y=0; y<(int)message.length(); y++);
   //counts the string
for(y-1; y>-1; y--). //takes the string and displays it backwards
   cout<<message[y];

That should display the string in reverse order, you could also use stacks or like he said you can use recursion.

commented: no -2
commented: Do NOT do people's homework for them. -2
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.