C Program to Reverse Array of Strings Last Updated : 20 Dec, 2018 Comments Improve Suggest changes Like Article Like Report Given an array of string literals, reverse the array. Examples: 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 // 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; j--; } } int main() { char* arr[] = { "Coding", "never", "fail", "me" }; int n = sizeof(arr) / sizeof(arr[0]); PrintArray(arr, n); printf("\n"); ReverseArray(arr, n); PrintArray(arr, n); return 0; } Output: Coding never fail me me fail never Coding Comment More infoAdvertise with us Next Article C Program to Reverse Array of Strings D DhanaSiggie Follow Improve Article Tags : C Language Similar Reads Program to Reverse a String using Pointers Given a string, the task is to reverse this String using pointers. Examples:Input: GeeksOutput: skeeGInput: GeeksForGeeksOutput: skeeGroFskeeGApproach: This method involves taking two pointers, one that points at the start of the string and the other at the end of the string. The characters are then 2 min read Array of Strings in C In C, an array of strings is a 2D array where each row contains a sequence of characters terminated by a '\0' NULL character (strings). It is used to store multiple strings in a single array.Let's take a look at an example:C#include <stdio.h> int main() { // Creating array of strings for 3 str 3 min read How to Empty a Char Array in C? Prerequisite: Char Array in C Char arrays are used for storing multiple character elements in a continuous memory allocated. In a few questions, we have the necessity to empty the char array but You canât clear a char array by setting the individual members to some value indicating that they donât c 4 min read How to store words in an array in C? We all know how to store a word or String, how to store characters in an array, etc. This article will help you understand how to store words in an array in C. To store the words, a 2-D char array is required. In this 2-D array, each row will contain a word each. Hence the rows will denote the index 2 min read C function to Swap strings Let us consider the below program. C #include<stdio.h> void swap(char *str1, char *str2) { char *temp = str1; str1 = str2; str2 = temp; } int main() { char *str1 = "geeks"; char *str2 = "forgeeks"; swap(str1, str2); printf("str1 is %s, str2 is %s", str1, str2); ge 2 min read Like