If you don't want to change the strings, then you could simply do

const char *a[2];
a[0] = "blah";
a[1] = "hmm";

When you do it like this you will allocate an array of two pointers to const char. These pointers will then be set to the addresses of the static strings "blah" and "hmm".

If you do want to be able to change the actual string content, the you have to do something like

char a[2][14];
strcpy(a[0], "blah");
strcpy(a[1], "hmm");

This will allocate two consecutive arrays of 14 chars each, after which the content of the static strings will be copied into them.

Answer from Mikael Auno on Stack Overflow
Top answer
1 of 15
306

If you don't want to change the strings, then you could simply do

const char *a[2];
a[0] = "blah";
a[1] = "hmm";

When you do it like this you will allocate an array of two pointers to const char. These pointers will then be set to the addresses of the static strings "blah" and "hmm".

If you do want to be able to change the actual string content, the you have to do something like

char a[2][14];
strcpy(a[0], "blah");
strcpy(a[1], "hmm");

This will allocate two consecutive arrays of 14 chars each, after which the content of the static strings will be copied into them.

2 of 15
252

There are several ways to create an array of strings in C. If all the strings are going to be the same length (or at least have the same maximum length), you simply declare a 2-d array of char and assign as necessary:

char strs[NUMBER_OF_STRINGS][STRING_LENGTH+1];
...
strcpy(strs[0], aString); // where aString is either an array or pointer to char
strcpy(strs[1], "foo");

You can add a list of initializers as well:

char strs[NUMBER_OF_STRINGS][STRING_LENGTH+1] = {"foo", "bar", "bletch", ...};

This assumes the size and number of strings in the initializer match up with your array dimensions. In this case, the contents of each string literal (which is itself a zero-terminated array of char) are copied to the memory allocated to strs. The problem with this approach is the possibility of internal fragmentation; if you have 99 strings that are 5 characters or less, but 1 string that's 20 characters long, 99 strings are going to have at least 15 unused characters; that's a waste of space.

Instead of using a 2-d array of char, you can store a 1-d array of pointers to char:

char *strs[NUMBER_OF_STRINGS];

Note that in this case, you've only allocated memory to hold the pointers to the strings; the memory for the strings themselves must be allocated elsewhere (either as static arrays or by using malloc() or calloc()). You can use the initializer list like the earlier example:

char *strs[NUMBER_OF_STRINGS] = {"foo", "bar", "bletch", ...};

Instead of copying the contents of the string constants, you're simply storing the pointers to them. Note that string constants may not be writable; you can reassign the pointer, like so:

strs[i] = "bar";
strs[i] = "foo"; 

But you may not be able to change the string's contents; i.e.,

strs[i] = "bar";
strcpy(strs[i], "foo");

may not be allowed.

You can use malloc() to dynamically allocate the buffer for each string and copy to that buffer:

strs[i] = malloc(strlen("foo") + 1);
strcpy(strs[i], "foo");

BTW,

char (*a[2])[14];

Declares a as a 2-element array of pointers to 14-element arrays of char.

🌐
GeeksforGeeks
geeksforgeeks.org › c language › array-of-strings-in-c
Array of Strings in C - GeeksforGeeks
July 23, 2025 - 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).
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_array_of_strings.htm
Array of Strings in C
To declare an array of strings, you need to declare a two-dimensional array of character types, where the first subscript is the total number of strings and the second subscript is the maximum size of each string.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › strings-in-c
Strings in C - GeeksforGeeks
July 8, 2026 - A string in C is a sequence of characters stored in a character array and terminated by the null character '\0'. Since C does not provide a built-in string data type, strings are represented using char arrays.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › c programming tutorial › strings array in c
Strings Array in C | What is an array of string? | Functions of strings
March 18, 2023 - C concept already explains that ... By the rule of initialization of array, the above declaration can be written as char str_name[] = "Strings";...
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
W3Schools
w3schools.com › c › c_strings.php
C Strings
Unlike many other programming languages, C does not have a String type to easily create string variables. Instead, you must use the char type and create an array of characters to make a string in C:
🌐
Unstop
unstop.com › home › blog › string array in c | a complete explanation (+code examples)
String Array In C | A Complete Explanation (+Code Examples)
March 19, 2024 - ... Note that all the elements in an array must be of the same data type. For example, in an integer array, the elements will be of integer data type. Similarly, a string is an array of character types since it is made up of characters.
Find elsewhere
🌐
Scaler
scaler.com › home › topics › what is an array of strings in c?
What is an Array of Strings in C? - Scaler Topics
April 30, 2024 - In C, an array represents a linear collection of data elements of a similar type, thus an array of strings means a collection of several strings. Learn more on Scaler Topics.
🌐
Wikibooks
en.wikibooks.org › wiki › C_Programming › Arrays_and_strings
C programming/Arrays and strings - Wikibooks, open books for an open world
August 11, 2003 - To get a char array with 3 rows ... based on the initializer list. ... C has no string handling facilities built in; consequently, strings are defined as arrays of characters....
🌐
DEV Community
dev.to › missmati › pointers-arrays-strings-in-c-52h3
Pointers , Arrays & Strings in C - DEV Community
October 11, 2022 - String array using the array of pointer to string: Similar to the 2D array we can create the string array using the array of pointers to strings. Basically, this array is an array of character pointers where each pointer points to the string’s first character.
🌐
Medium
medium.com › @mdsiaofficial › array-of-strings-in-c-programming-fd5755ccd3f8
Array of Strings in C programming | by Md Shoriful Islam Ashiq | Medium
April 2, 2024 - #include<stdio.h> #include<stdlib.h> #include<string.h> int main(){ char s[MAX_NAME] = "Ashiq"; char* ss[] = {"ash", "che", "ashiq", "chester"}; int length = sizeof(ss)/sizeof(ss[0]); int sizeofarray = sizeof(ss); printf("length: %d\n", length); printf("Size of array: %d\n", sizeofarray); // The size of the [ss] array is 32 for(int i=0; i<length; i++){ printf("%s\n", ss[i]); } return 0; }
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_strings.htm
Strings in C
A string in C is a one-dimensional array of char type, with the last character in the array being a "null character" represented by '\0'. Thus, a string in C can be defined as a null-terminated sequence of char type values.
🌐
Delft Stack
delftstack.com › "delft stack" › "howto" › "c howtos" › "array of strings in c"
Array of Strings in C | Delft Stack
October 12, 2023 - The whole array can be initialized with {""} notation, which zeros out each char element in the array. When storing the string values in the already initialized array, the assignment operator is not permitted, and special memory copying functions should be employed like strcpy.
🌐
Aticleworld
aticleworld.com › home › array of strings in c
Array of Strings in C - Aticleworld
February 26, 2023 - Now you are going to learn how you can create an array of strings using the 1D array. This array will be the array of character pointers. In this each pointer point to a string. You should remember that if it points to a literal string, then you can not modify its value.
🌐
Medium
medium.com › @milankathiriya › string-in-c-language-021fc8144314
String in C language. A string is an array of characters… | by Milan Kathiriya | Medium
April 9, 2024 - Strings in C are represented as character arrays, where each element of the array is a character in the string, and the null character \0 indicates the end of the string.
🌐
LabEx
labex.io › questions › how-to-declare-an-array-of-strings-in-c-136081
How to Declare an Array of Strings in C | LabEx
July 25, 2024 - ## Declaring an Array of Strings in C In the C programming language, you can declare an array of strings by creating an array of character pointers.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › how-to-create-a-dynamic-array-of-strings-in-c
How to Create a Dynamic Array of Strings in C? - GeeksforGeeks
July 23, 2025 - To create a dynamic array of strings in C, we can use the concept of double pointer and dynamic memory allocation. The double pointer is the pointer that stores the memory address of another pointer.
🌐
Programiz
programiz.com › c-programming › c-strings
C Programming Strings | Programiz
August 28, 2021 - Arrays and strings are second-class citizens in C; they do not support the assignment operator once it is declared.
🌐
Medium
medium.com › @divyasrdj › programming-in-c-arrays-strings-1695160875a3
Programming in C — Arrays & Strings | by Divya Stephen | Medium
June 16, 2025 - Arrays and strings are second-class citizens in C; they do not support the assignment operator once it is declared.