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
305

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
251

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 - We can't directly change or assign the values to an array of strings in C.
🌐
TutorialsPoint
tutorialspoint.com › home › cprogramming › c array of strings
C Array of Strings
June 10, 2012 - ... 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.
🌐
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 - Initialization in C means to provide the data to the variable at the time of declaration. It is straightforward to initialize an array of strings. We can create an array of some size and then place comma-separated strings inside that.
🌐
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.
🌐
Quora
quora.com › How-can-I-declare-an-array-of-strings-in-C-an-example-would-be-helpful
How to declare an array of strings in C (an example would be helpful) - Quora
Answer (1 of 6): While you could create a two-dimensional array of characters, where each row of the array is the beginning of a new string, this approach artificially limits the length of the strings in the array (the limit is the number of columns in the array minus one, for the null-terminatio...
🌐
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.
Find elsewhere
🌐
Reddit
reddit.com › r/learnprogramming › [c] can i store strings into an array ?
r/learnprogramming on Reddit: [C] Can I store strings into an array ?
October 5, 2021 -

I know that strings are char arrays already and I was wondering if there's a way to store not strings in an array. It would be like storing arrays into an array and that sounds a bit weird.

As far as I know an array is a pointer so I'd tend to say no, but after all pointers are just storing numbers like any variable.

To maybe be clearer, what I'd want to do is have an array that's like that :

array[0] = BLUE

array[1] = RED

array [2] = YELLOW

etc

🌐
OverIQ
overiq.com › c-programming-101 › array-of-strings-in-c
Array of Strings in C - C Programming Tutorial - OverIQ.com
A string is a 1-D array of characters, so an array of strings is a 2-D array of characters. Just like we can create a 2-D array of int, float etc; we can also create a 2-D array of character or array of strings. Here is how we can declare a 2-D array of characters. It is important to end each 1-D array by the null character, otherwise, it will be just an array of characters.
🌐
WsCube Tech
wscubetech.com › resources › c-programming › array-of-strings
Array of Strings in C Language (With Examples)
November 10, 2025 - Learn how to create and use an array of strings in C programming. Explore different methods and operations with examples, output, and explanations. Read now!
🌐
Big Nerd Ranch
forums.bignerdranch.com › objective-c programming (2nd edition) › 39. c strings
How would I make a array of strings in C? - 39. C Strings - Big Nerd Ranch Book Forums
June 25, 2022 - How would I make a array of strings in C · Alternatively, you could have a be an array of two character pointers which could point to strings of any length: · Given a value of type T = char *: // Type for a 1D array of strings char * [] // Typical use case void foo (char * [5]) // number ...
🌐
W3Schools
w3schools.com › c › c_strings.php
C Strings
You can also loop through the characters of a string, using a for loop: char carName[] = "Volvo"; int i; for (i = 0; i < 5; ++i) { printf("%c\n", carName[i]); } Try it Yourself » · And like we specified in the arrays loop chapter, you should use the sizeof formula (instead of manually write the size of the array in the loop condition (i < 5)) to make the loop more sustainable:
🌐
Delft Stack
delftstack.com › home › howto › array of strings in c
Array of Strings in C | Delft Stack
October 12, 2023 - In this case, we arbitrarily define a macro constant - MAX_LENGTH equal to 100 characters. The whole array can be initialized with {""} notation, which zeros out each char element in the array.
🌐
Codecademy
codecademy.com › learn › learn-c-arrays-and-strings
Learn C: Arrays and Strings | Codecademy
This course covers creating, accessing, and modifying arrays, as well as using arrays to handle strings, which are essential for writing functional and optimized programs in C. ... Learn about arrays and strings in C. ... Earn a certificate of completion and showcase your accomplishment on your resume or LinkedIn. ... Make progress faster with our AI Learning Assistant, a tool that automatically understands your current course, instructions, and solution code — and gives you instant, personalized feedback.
Rating: 4.6 ​ - ​ 265 votes
🌐
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 - Inside main(), we declare a string array Unstop, which can contain 3 strings of character size 8 each. We initialize it using the initializer list, which contains string literals as elements. Then, we use a printf() statement inside a for loop to print the elements to the console. Next, we declare another string array, Unstop2, and initialize it with the same elements as before. But in this case, the main initializer list contains lists with character literals that make up the string.
🌐
Medium
medium.com › @divyasrdj › programming-in-c-arrays-strings-1695160875a3
Programming in C — Arrays & Strings | by Divya Stephen | Medium
June 16, 2025 - :) To create an array, define the data type (like int) and specify the name of the array followed by square brackets []. To insert values to it, use a comma-separated list inside curly braces, and make ...
🌐
SkillVertex
skillvertex.com › blog › array-of-strings-in-c
Array Of Strings In C -
May 10, 2024 - In C, an array of strings is typically represented as a one-dimensional array of strings, where each element of the array is a pointer to a string (which is essentially a one-dimensional array of characters).
🌐
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 - A String can be defined as a one-dimensional array of characters, so an array of strings is two –dimensional array of characters. ... From the given syntax there are two subscripts first one is for how many strings to declare and the second is to define the maximum length of characters that each string can store including the null character.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai