Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

C Program to Reverse Array of Strings

  • Last Updated : 20 Dec, 2018

Given an array of string literals, reverse the array.


We provide nothing but the best curated videos and practice problems for our students. Check out the C Foundation Course and master the C language from basic to advanced level. Wait no more, start learning today!
Input :  arr[] = {"Coding", "Never",  "Fail",  "Me"} 
Output : arr[] = {"Me", "Fail", "Never", "Coding"}

Input : arr[] = {"welcome", "to", "geeksforgeeks"} 
Output : arr[] = {"geeksforgeeks", "to", "welcome"}  

The idea is to create an array of pointers, store string literals in it. To reverse the array, we start from begin and end, and move both pointers toward each other. While moving, we keep swapping pointers.

// C program to reverse an array of strings
#include <stdio.h>
#include <string.h>
void PrintArray(char* arr[], int n)
    for (int i = 0; i < n; i++) {
        printf("%s ", arr[i]);
void ReverseArray(char* arr[], int n)
    char* temp;
    // Move from begin and end. Keep
    // swapping strings. 
    int j = n - 1;
    for (int i = 0; i < j; i++) {
        temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
int main()
    char* arr[] = { "Coding", "never", "fail", "me" };
    int n = sizeof(arr) / sizeof(arr[0]);
    PrintArray(arr, n);
    ReverseArray(arr, n);
    PrintArray(arr, n);
    return 0;
Coding never fail me 
me fail never Coding

My Personal Notes arrow_drop_up
Recommended Articles
Page :