How to store words in an array in C? Last Updated : 18 Oct, 2019 Comments Improve Suggest changes Like Article Like Report 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 number of the words and the column number will denote the particular character in that word. Direct initialization: In this method, the words are already known and the 2-D char array is created with these words directly. Syntax for Direct initialization: char array[][20] = {"Geek1", "Geek2", "Geek3", ..."}; Syntax for accessing a word: Lets say we need to fetch the ith word: array[i] Below is the implementation of the above approach: C // C program to store words in an array #include <stdio.h> int main() { int i; // Direct initialization of 2-D char array char array[][20] = { "Geek1", "Geek2", "Geek3" }; // print the words for (i = 0; i < 3; i++) printf("%s\n", array[i]); return 0; } Output: Geek1 Geek2 Geek3 By taking input from user: In this method, the number of words and words are given by the user and we have to create and map the 2-D char array for each word. Syntax: // Declaration of 2-D char array // where n is the number of words char array[n][20]; // Initialization of 2-D char array for (i = 0; i < n; i++) scanf("%s", array[i]); Syntax for accessing a word: Lets say we need to fetch the ith word: array[i] Below is the implementation of the above approach: C // C program to store words in an array #include <stdio.h> int main() { int i; // Lets say we have 3 words int n = 3; // Declaration of 2-D char array char array[n][20]; // Initialization of 2-D char array for (i = 0; i < 3; i++) scanf("%s", array[i]); // print the words for (i = 0; i < 3; i++) printf("%s\n", array[i]); return 0; } Input: Geek1 Geek2 Geek3 Output: Geek1 Geek2 Geek3 Comment More infoAdvertise with us Next Article How to store words in an array in C? C code_r Follow Improve Article Tags : C Language C-String Similar Reads C Program to Insert an Element in an Array In this article, we will learn how to insert an element into an array in C.C arrays have a fixed size, so we cannot dynamically increase their memory. However, we can insert an element if the array already have enough memory space to accommodate the new elementsInsert Element at Specific PositionTo 3 min read Pointer vs Array in C Most of the time, pointer and array accesses can be treated as acting the same, the major exceptions being:  1. the sizeof operator sizeof(array) returns the amount of memory used by all elements in the array sizeof(pointer) only returns the amount of memory used by the pointer variable itself 2. 1 min read Array of Pointers in C In C, a pointer array is a homogeneous collection of indexed pointer variables that are references to a memory location. It is generally used in C Programming when we want to point at multiple memory locations of a similar data type in our C program. We can access the data by dereferencing the point 6 min read How to declare a Two Dimensional Array of pointers in C? A Two Dimensional array of pointers is an array that has variables of pointer type. This means that the variables stored in the 2D array are such that each variable points to a particular address of some other element. How to create a 2D array of pointers: A 2D array of pointers can be created follo 3 min read Maximum Size of an Array in C Array in C is a collection of elements of the same data type that are stored in contiguous memory locations. The size of an array is determined by the number of elements it can store and there is a limit on this size. The maximum size of an array in C is determined by many factors, including the dat 4 min read Like