physics chemistry maths science forums
become expert I help I sign up I login
refer a friend - earn nickels!!   
 advanced
 
Home
Ask & Discuss Questions
Study Material
Experts Zone
Hang Out!

Ask & Discuss Questions with Community & Experts

   advanced

Ask iit jee aieee pet cbse icse state board experts Expert Question: How to reverse a string in c++ ?
Forum Index -> Computer Science like the article? email it to a friend. email this article!  
Author Message
biswajeet7 (0)

New kid on the Block

Olaaa!! Perrrfect answer. 0  [0 rates]

biswajeet7's Avatar

total posts: 1    
offline Offline
How to reverse a string in c++ ?
 
    
priyesh (1485)

Blazing goIITian

Olaaa!! Perrrfect answer. 239  [384 rates]

priyesh's Avatar

total posts: 923    
offline Offline
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 Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
srini (276)

Blazing goIITian

Olaaa!! Perrrfect answer. 44  [72 rates]

srini's Avatar

total posts: 521    
offline Offline
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 Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
nadeemoidu (1174)

Blazing goIITian

Olaaa!! Perrrfect answer. 198  [290 rates]

nadeemoidu's Avatar

total posts: 474    
online Online
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 Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
puneet (3251)

Forum Expert Blazing goIITian

Olaaa!! Perrrfect answer. 569  bad job dude!! I dont approve of this answer! 2  [776 rates]

puneet's Avatar

total posts: 1663    
offline Offline
hii

well the write answer ..

cheers


Puneet Agrawal
IIT Delhi
 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
 
Forum Index -> Computer Science
Go to:   

Top Offers for goIITians
Correspondence Courses
Brilliant Tutorials
Narayana Institute
Aakash Institute
Classroom/Crash Courses
Narayana - Kota , Delhi , Others
Brilliant Tutorials - Class , Crash
Aakash Institute - Medical , Engg
Online Test Series
Brilliant Tutorials
Narayana Institute
Aakash Institute
Mahesh Tutorials
AMITY      Sri Chaitanya