C Program to Reverse a String Using Recursion Last Updated : 15 Dec, 2024 Comments Improve Suggest changes 3 Likes Like Report Reversing a string means changing the order of characters in the string so that the last character becomes the first character of the string. In this article, we will learn how to reverse a string using recursion in a C program.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: C #include <stdio.h> #include <string.h> // Function to reverse string using recursion void revRecursive(char *l, char *r) { // Till two pointers do not meet, // swap the values they point to if (l != r) { char c = *l; *l = *r; *r = c; // Recursive call revRecursive(l + 1, r - 1); } } // Wrapper function void rev(char *s) { // Calling the recursive function revRecursive(s, s + strlen(s) - 1); } int main() { char s[] = "GeeksforGeeks"; // Reversing the string s rev(s); printf("%s", s); return 0; } OutputskeeGrofskeeG Comment K kartik Follow 3 Improve K kartik Follow 3 Improve Article Tags : C Programs C Language C Strings Programs Explore C BasicsC Language Introduction6 min readIdentifiers in C3 min readKeywords in C2 min readVariables in C4 min readData Types in C3 min readOperators in C8 min readDecision Making in C (if , if..else, Nested if, if-else-if )7 min readLoops in C6 min readFunctions in C5 min readArrays & StringsArrays in C4 min readStrings in C6 min readPointers and StructuresPointers in C9 min readFunction Pointer in C6 min readUnions in C4 min readEnumeration (or enum) in C5 min readStructure Member Alignment, Padding and Data Packing8 min readMemory ManagementMemory Layout of C Programs5 min readDynamic Memory Allocation in C7 min readWhat is Memory Leak? How can we avoid?2 min readFile & Error HandlingFile Handling in C11 min readRead/Write Structure From/to a File in C3 min readError Handling in C8 min readUsing goto for Exception Handling in C4 min readError Handling During File Operations in C5 min readAdvanced ConceptsVariadic Functions in C5 min readSignals in C language5 min readSocket Programming in C8 min read_Generics Keyword in C3 min readMultithreading in C9 min read Like