C Online Compiler
Example: Reverse String with strrev in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Reverse String with strrev #include <stdio.h> #include <string.h> // Required for strrev and strlen (on systems where strrev is available) int main() { // Step 1: Declare and initialize a character array (string) char str[] = "hello world"; printf("Original string: %s\n", str); // Step 2: Reverse the string using strrev // NOTE: strrev is non-standard and might not be available on all compilers (e.g., GCC) strrev(str); // Step 3: Print the reversed string printf("Reversed string: %s\n", str); return 0; }
Output
Clear
ADVERTISEMENTS