cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : UNIX/Linux Programming : strrev in unix
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Articles
Lounge
Jobs

-

question  strrev in unix

detorresrc
1
2
3
4
5
6
7
#include <string.h>

int main(){
  char mystring[100];
  strcpy(mystring, "Rommel");
  strrev(mystring);
}


#ERROR
`strrev' undeclared (first use this function)

please help me how to fix this.
|
jsmith
I assume strrev() reverses the string? There is no such equivalent to the best of my knowledge. You'll need to implement your own.

1
2
3
4
5
6
7
#include <algorithm>

template< typename T, size_t N >
void reverse_array( T array[ N ] ) {
   for( size_t i = 0; i < N / 2; ++i )
       std::swap( array[ i ], array[ N-i-1 ] );
}
|

Registered users can reply in this forum.
Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us