Array of Pointers to Strings in C Last Updated : 04 Apr, 2024 Comments Improve Suggest changes Like Article Like Report In C, arrays are data structures that store data in contiguous memory locations. Pointers are variables that store the address of data variables. We can use an array of pointers to store the addresses of multiple elements. In this article, we will learn how to create an array of pointers to strings in C. Array of Pointers to Strings in CAn array of pointers to strings is a data structure where each element is a pointer that points to a string. It is a very effective technique when we want to point at different memory locations of the same data type like a string. Syntax to Create an Array of Pointers to Strings in CTo create an array of pointers to strings in C we can use the following syntax: char * arr[size] ={ "String1", "String2", ....}Here, char*: is the type of pointers we will store in the array.arr: is the name of the array of pointers.size: is the size of the array of pointers.Each array element will act as a pointer to the first character of an individual string. Note: Storing the strings in this array is more efficient than storing multiple strings in a 2D Array of characters as explained here. C Program to Create an Array of Pointers to Strings The following program illustrates how we can create an array of pointers to strings in C. C // C Program to Create an Array of Pointers to Strings #include <stdio.h> int main() { // Initialize an array of pointers to strings char* arr[4] = { "C++", "Java", "Python", "JavaScript" }; int n = sizeof(arr) / sizeof(arr[0]); // Print the strings using the pointers printf("Array Elements:\n"); for (int i = 0; i < n; i++) { printf("%s\n", arr[i]); } return 0; } OutputArray Elements: C++ Java Python JavaScript Time Complexity: O(N) where N is the number of strings.Auxiliary Space: O(N * M), where M is the average length of the strings. Comment More infoAdvertise with us Next Article Array of Pointers to Strings in C R ruchiluckysripada Follow Improve Article Tags : C Programs C Language C-Pointers C-Arrays C-String C Examples +2 More Similar Reads How to Reverse a String in C? In C, a string is a sequence of characters terminated by a null character (\0). Reversing a string means changing the order of the characters such that the characters at the end of the string come at the start and vice versa. In this article, we will learn how to reverse a string in C. Example: Inpu 2 min read How to Initialize Array of Pointers in C? Arrays are collections of similar data elements that are stored in contiguous memory locations. On the other hand, pointers are variables that store the memory address of another variable. In this article, we will learn how to initialize an array of pointers in C. Initialize Array of Pointers in CWe 2 min read How to Create a Dynamic Array of Strings in C? In C, dynamic arrays are essential for handling data structures whose size changes dynamically during the program's runtime. Strings are arrays of characters terminated by the null character '\0'. A dynamic array of strings will ensure to change it's size dynamically during the runtime of the progra 3 min read How to Convert a String to a Char Array in C? In C, the only difference between the string and a character array is possibly the null character '\0' but strings can also be declared as character pointer in which case, its characters are immutable. In this article, we will learn how to convert a string to a char array in C.The most straightforwa 2 min read How to Split a String by a Delimiter in C? Splitting a string by a delimiter is a common task in programming. In C, strings are arrays of characters, and there are several ways to split them based on a delimiter. In this article, we will explore different methods to split a string by a delimiter in C. Splitting Strings in CThe strtok() metho 2 min read How to Iterate Through Array of Structs in C? In C, while working with an array of structs we have to iterate through each struct in an array to perform certain operations or access its members. In this article, we will learn how to iterate through an array of the structs in C. Iterate Over of an Array of StructuresTo iterate through an array o 2 min read C Program to Print the Length of a String using Pointers C language provides a built-in function strlen() but in this article, we will learn how to find and print the length of the string using pointers in C.The easiest method to find the length of a string using pointers is by calculating difference between the pointers to the first and last character of 2 min read How to Initialize Char Array in Struct in C? In C++, we can also define a character array as a member of a structure for storing strings. In this article, we will discuss how to initialize a char array in a struct in C. Initialization of Char Array in Struct in CWhen we create a structure instance (variable) in C that includes a char array, we 2 min read How to Initialize Array to 0 in C? Initializing an array to zero is a common practice in programming to ensure that all elements start with a known value. In C, there are several ways to initialize an array to zero. In this article, we will explore different methods to do so. Initialize Array to 0 in CThere are mainly two ways to ini 2 min read C Program to Split a String into a Number of Sub-Strings In this article, we will learn how to split a string into a number of sub-strings using the C program.The most straightforward method to split a string into substrings using a delimiter is by using strtok() function. Letâs take a look at an example:C#include <stdio.h> #include <string.h> 3 min read Like