Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reverse routine in CPP

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Can anyone help me to write a code in CPP which will implement a reverse routine and the output as follows:


original string: hello world

reverse string: dlrow olleh


I need help. Thanks. I am using Borland Compiler so the program must be in CPP.
 
const int size = 21;
char* s = new char[size];
strcpy(s, &quot;Hello World&quot;); // include <string.h>

for (int i = strlen(s); i > 0; i--)
cout << s;

delete [] s;
 
Okay this is making me mad.

where it says

cout << s;

put

cout << s(left bracket i right bracket)
cout << s;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top