String reverse

Implement a function void reverse(char* str) in C or C++ which reverses a null terminated string.

C++:
01 void reverse(char* str)
02 {
03     int n=0;
04     while(str[n]!=)
05         n++;
06     for(int i=0;i<n/2;i++){
07         char c=str[i];
08         str[i]=str[n1i];
09         str[n1i]=c;
10     }
11 }
Advertisements
This entry was posted in String. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s