strrev in unix
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.
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 ] );
}
| |
Topic archived. No new replies allowed.