#include <stdio.h> #include <string.h> void reverse_string_recursive(char *str) { if (*str == '\0') { return; } reverse_string_recursive(str + 1); printf("%c", *str); } int main() { char input_string[] = "hello world"; printf("Original string: %s\n", input_string); printf("Reversed string: "); reverse_string_recursive(input_string); printf("\n"); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter