Following is one way to reverse string using recursion!

#include <stdio.h>
#include <string.h>

void rev_str_recursive(char arr[], size_t iStart, size_t iLast)
{
    if( iStart < iLast )
    {
        //swap
        char temp = arr[iStart];
        arr[iStart] = arr[iLast];
        arr[iLast] = temp;

        rev_str_recursive(arr, ++iStart, --iLast);  
    }
}

void main()
{
    char cArray[] = {"A quick brown fox jumps over a lazy dog"};

    rev_str_recursive(cArray, 0, strlen(cArray)-1);
}
Answer from AFI on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ c-program-to-reverse-a-string-using-recursion
C Program to Reverse a String Using Recursion - GeeksforGeeks
January 24, 2026 - The string can be reversed by using two pointers: one at the start and one at the end. Swap the values of these two pointers while moving the pointers towards each other. Letโ€™s take a look at an example: ... #include <stdio.h> #include <string.h> ...
Discussions

Reversing a string in C using Recursion - Stack Overflow
I have written a program to reverse a string using recursion. But the output I get is an empty string always. I want to know what is wrong with my logic? #include void reverse(ch... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Reverse a sentence using recursion
It works to reverse the sentence, because of the order of two inner lines of reverseSentence().eg, if printf was called before recursing, then the sentence would print out in-order. Because the order is to recurse first, then printf, the first character captured is the last to be printed to the screen. More on reddit.com
๐ŸŒ r/C_Programming
6
2
September 26, 2022
[C++] Errors when trying to write a reversing string with recursion

but I keep getting errors and my code won't compile.

Tell us those errors.

I'm coding in vim and I don't know how to copy/paste.

Put set clipboard=unnamed somewhere in your vimrc. Then the system-wide clipboard (or X clipboard on Linux) will be used for yanking and pasting by default in vim. I like Shift+v for visual line selection, then y for yanking the selection.

(However, vim masters would tell you to learn motions so that you wouldn't have to use the visual mode, and they'd also tell you to read :help registers.)

More on reddit.com
๐ŸŒ r/learnprogramming
4
1
October 8, 2016
C++ using Recursion for a reverse Fibonacci and binary To Decimal function

Your posts seem to contain unformatted code. Please make sure to format your code otherwise your post may be removed.

Read our guidelines for how to format your code.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

More on reddit.com
๐ŸŒ r/cpp_questions
4
0
February 15, 2019
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2014 โ€บ 06 โ€บ c-program-to-reverse-a-string-using-recursion
C program to Reverse a String using recursion
#include <stdio.h> #include <string.h> // Function to reverse a string using recursion void reverseString(char* str, int start, int end) { if (start >= end) { return; } // Swap the characters at start and end char temp = str[start]; str[start] = str[end]; str[end] = temp; // Recursively calling ...
๐ŸŒ
Programiz
programiz.com โ€บ c-programming โ€บ examples โ€บ reverse-sentence-recursion
C Program to Reverse a Sentence Using Recursion
Find the Frequency of Characters in a String ยท Add Two Matrices Using Multi-dimensional Arrays ยท Calculate the Sum of Natural Numbers ยท To understand this example, you should have the knowledge of the following C programming topics: C Functions ยท C User-defined functions ยท C Recursion ยท #include <stdio.h> void reverseSentence(); int main() { printf("Enter a sentence: "); reverseSentence(); return 0; } void reverseSentence() { char c; scanf("%c", &c); if (c != '\n') { reverseSentence(); printf("%c", c); } } Output ยท
๐ŸŒ
Sanfoundry
sanfoundry.com โ€บ c-program-reverse-string-using-recursion-2
C Program to Reverse a String using Recursion - Sanfoundry
May 13, 2022 - Again call the reverse() function by passing the value of โ€˜str1โ€™ variable and the summation of the value of โ€˜indexโ€™ variable with 1 and the value of โ€˜sizeโ€™ variable as argument.
๐ŸŒ
Quora
quora.com โ€บ How-do-you-reverse-a-string-using-recursion-in-C-and-C-programming
How to reverse a string using recursion in C++ and C programming - Quora
Answer: A string is a one dimensional character array that is terminated by a null character. The reverse of a string is the same string in opposite order. For example. [code]Original String: Apple is red Reversed String: der si elppA [/code]A program that reverses a sentence in the form of a st...
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ c-program-to-reverse-a-string-using-recursion
C Program to Reverse a String using Recursion
April 5, 2025 - #include <stdio.h> #include <string.h> void stringReverse(char *Str, int i, int len) { char temp; if (i >= len) { return; } temp = *(Str + i); *(Str + i) = *(Str + len); *(Str + len) = temp; stringReverse(Str, ++i, --len); } int main() { char Str[100]; printf("\nPlease Enter any Text = "); fgets(Str, sizeof Str, stdin); stringReverse(Str, 0, strlen(Str) -1); printf("\nResult = %s\n", Str); return 0; } Please Enter any Text = hello c programmers Result = sremmargorp c olleh ยท It is another example to reverse a string using recursion.
Find elsewhere
๐ŸŒ
Hero Vired
herovired.com โ€บ learning-hub โ€บ blogs โ€บ reverse-a-string-in-c
C Program to Reverse a String Using for Loop and Recursion
... There are multiple ways to ... characters until reaching the middle. The other methods are using the strrev() function, using pointers, recursion, and stack....
๐ŸŒ
w3resource
w3resource.com โ€บ c-programming-exercises โ€บ recursion โ€บ c-recursion-exercise-9.php
C Program: Get reverse of a string - w3resource
The variable i is used to keep track of the index of the reversed string and is initialized to 0. The variable revstr is used to store the reversed string. The function checks if the first character of the input string is not null. If it is not null, the function calls itself recursively with the input string pointer incremented by 1 (i.e., the address of the second character).
๐ŸŒ
Techie Delight
techiedelight.com โ€บ home โ€บ basic โ€บ reverse a string using recursion โ€“ c, c++, and java
Reverse a string using recursion โ€“ C, C++, and Java | Techie Delight
September 19, 2025 - Write a recursive program to efficiently reverse a given string in C, C++, and Java... As seen in the previous post, we can easily reverse a given string using a stack data structure.
๐ŸŒ
YouTube
youtube.com โ€บ portfolio courses
Use Recursion To Print String In Reverse | C Programming Example - YouTube
Print a string in reverse using recursion in C. Source code: https://github.com/portfoliocourses/c-example-code/blob/main/print_reverse_recursive.c. Check ...
Published ย  September 18, 2021
Views ย  25K
๐ŸŒ
Techcrashcourse
techcrashcourse.com โ€บ 2015 โ€บ 03 โ€บ c-program-to-reverse-string-using-recursion.html
C Program to Reverse a String using Recursion
We will first call reverse function by passing following parameters reverse("ORANGE", 0, 5). Then reverse function will swap the positions of character 'O'(leftmost character) and 'E'(rightmost character) and recursively calls itself to reverse inner substring as reverse("ERANGO", 1, 4) and so on.
๐ŸŒ
Sanfoundry
sanfoundry.com โ€บ c-program-reverse-string
Reverse a String in C - Sanfoundry
October 18, 2023 - Enter String: hello world Entered ... Recursive Approach, we swap the character at index i with character at index (n-i-1), where n is the size of the string, until i reaches the middle of the string....
๐ŸŒ
YouTube
youtube.com โ€บ watch
print reverse of string using recursion in c - YouTube
Hello guys, in this video you will learn to create a recursive function which prints string in reverse order in c language.Noteshttps://github.com/tarrunverr...
Published ย  December 19, 2022
๐ŸŒ
Unstop
unstop.com โ€บ home โ€บ blog โ€บ reverse a string in c in 10 different ways (+code examples)
Reverse A String In C In 10 Different Ways (+Code Examples)
September 13, 2024 - We define a function reverseString() to reverse a string using recursion. It takes three parameters: char * (a pointer to a string), start (starting index of the string), and end ( ending index of the string).
๐ŸŒ
Vultr
docs.vultr.com โ€บ clang โ€บ examples โ€บ reverse-a-sentence-using-recursion
C Program to Reverse a Sentence Using Recursion | Vultr Docs
November 22, 2024 - By entering into deeper levels of function calls with each character and unwinding those calls in the opposite order, the program effectively reverses the order of characters in the sentence.
๐ŸŒ
Studytonight
studytonight.com โ€บ c โ€บ programs โ€บ recursion โ€บ reverse-a-string-using-recursion
C Program to Reverse A String Using Recursion | C Programs | Studytonight
#include<stdio.h> #include<conio.h> // declaring recursive function char* reverse(char* str); void main() { int i, j, k; char str[100]; char *rev; printf("Enter the string:\t"); scanf("%s", str); printf("The original string is: %s\n", str); rev = reverse(str); printf("The reversed string is: ...