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 Reverse a string in C/C++ using Client Server model This article describes a Client and Server setup where a Client connects, sends a string to server and the server shows the original string and sends reversed string to client using socket connection. Prerequisite : Socket Programming Examples: Input : welcome Output :emoclew Input :geeks for geeks 3 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 Check if a string is palindrome in C using pointers Given a string. The task is to check if the string is a palindrome or not using pointers. You are not allowed to use any built-in string functions. A string is said to be a palindrome if the reverse of the string is same as the original string. For example, "madam" is palindrome because when the str 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 Get a Substring in C A substring is a contiguous sequence of characters within a string. In this article, we will learn how to extract a substring using a C program.The simplest method to get a substring from a larger string is by using strncpy() function. Letâs take a look at an example:C++#include <stdio.h> #inc 2 min read Print Substring of a Given String Without Using Any String Function and Loop in C In C, a substring is a part of a string. Generally, we use string libary functions or loops to extract the substring from a string and then print it. But in this article, we will learn how to print the substring without using any string function or loops.The simplest method for printing a substring 2 min read Strings in C A String in C programming is a sequence of characters terminated with a null character '\0'. The C String is work as an array of characters. The difference between a character array and a C string is that the string in C is terminated with a unique character '\0'.DeclarationDeclaring a string in C i 5 min read Like