| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 27 Mar 2008 20:45:57 IST
|
|
|
How to reverse a string in c++ ?
|
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 27 Mar 2008 21:26:46 IST
|
|
|
reverse the loop to display reverse write
for(i=length of array;i>=0;i++) cout<
|
"Imagination is more important than knowledge."
|
this reply: 0 points
(with 0 
in 0 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 27 Mar 2008 22:56:45 IST
|
|
|
Hey, shouldn't that be i--? for len=strlen(str)
|
GIVE LIFE THE BEST....srini...
DO OR DIE, OR BETTER NEVER TRY!!
I dont want to be the most intelligent among the ten.i pray the other nine RE fools!???!!!!!!
it doesn't matter if you win... whats important to me is i win!!!!!!!! |
this reply: 0 points
(with 0 
in 0 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 28 Mar 2008 00:16:27 IST
|
|
|
the function strrev(str) in the header file string.h will reverse the string.
if u want to reverse it ( displaying in the reverse order is not same as reversing) use this,
char t; for( int i=0, j= strlen(s)-1 ; i<j; i++ , j--) { t=s[i]; s[i]=s[j]; s[j]=t; }
|
this reply: 0 points
(with 0 
in 0 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 28 Mar 2008 01:38:46 IST
|
|
|
hii
well the write answer ..
cheers
|
Puneet Agrawal
IIT Delhi
|
this reply: 0 points
(with 0 
in 0 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
|
|