![]() |
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,
Each array element will act as a pointer to the first character of an individual string.
C Program to Create an Array of Pointers to StringsThe following program illustrates how we can create an array of pointers to strings in C.
Output Array Elements: C++ Java Python JavaScript Time Complexity: O(N) where N is the number of strings. |
Reffered: https://www.geeksforgeeks.org
C Language |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 16 |