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.

🌐
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:
🌐
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).
🌐
OverIQ
overiq.com › c-programming-101 › array-of-strings-in-c
Array of Strings in C - C Programming Tutorial - OverIQ.com
The ch_arr is a pointer to an array of 10 characters or int(*)[10]. Therefore, if ch_arr points to address 1000 then ch_arr + 1 will point to address 1010. ... ch_arr + 0 points to the 0th string or 0th 1-D array. ch_arr + 1 points to the 1st string or 1st 1-D array.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › strings-in-c
Strings in C - GeeksforGeeks
November 14, 2025 - Unlike many modern languages, C does not have a built-in string data type. Instead, strings are implemented as arrays of char.
🌐
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.
🌐
W3Schools
w3schools.in › c-programming › strings
C Strings - W3Schools
In C programming, one-dimensional arrays of characters are called strings, terminated by a null character '\0'. In this tutorial, you will learn about C Strings, how it works in the C language and how you can use them in your C program.
Find elsewhere
🌐
W3Schools
w3schools.com › cs › cs_arrays.php
C# Arrays
We have now declared a variable that holds an array of strings. To insert values to it, we can use an array literal - place the values in a comma-separated list, inside curly braces:
🌐
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 - Here, the smaller box represents an array of characters (character blocks), i.e., strings, and the big box represents an array of strings. In this article, we will elaborate on how to declare and initialize a string array in C, its implementation, string functions and their uses, and more with the help of proper examples.
🌐
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!
🌐
Programiz
programiz.com › c-programming › c-strings
Strings in C (With Examples)
In this tutorial, you'll learn about strings in C programming. You'll learn to declare them, initialize them and use them for various I/O operations with the help of examples.
🌐
W3Schools
w3schools.com › c › c_arrays.php
C Arrays
C Examples C Real-Life Examples ... Q&A C Certificate ... Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value....
🌐
Emory
cs.emory.edu › ~cheung › Courses › 255 › Syllabus › 2-C-adv-data › string.html
Strings in C --- arrays of char
Prog file: click here · How to run the program: String: array of characters or a (char *) We have just seen that a · string in C is stored as an · array of characters · Fact: Reason: Example: function with a · string variable · Example Program: (Demo above code) &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp ·
🌐
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 - Strings, like "Hello, World!" from the intro exercise, aren't their own data type in C. They are arrays of char.
🌐
Codecademy
codecademy.com › learn › learn-c-arrays-and-strings
Learn C: Arrays and Strings | Codecademy
These fundamental data structures allow you to store and manipulate data collections efficiently. This course covers creating, accessing, and modifying arrays, as well as using arrays to handle strings, which are essential for writing functional ...
Rating: 4.6 ​ - ​ 265 votes
🌐
Learn C
learn-c.org › en › Strings
Strings - Learn C - Free Interactive C Tutorial
If we wish to define a string which can be manipulated, we will need to define it as a local character array: ... This notation is different because it allocates an array variable so we can manipulate it. The empty brackets notation [] tells the compiler to calculate the size of the array automatically. This is in fact the same as allocating it explicitly, adding one to the length of the 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.
🌐
Studytonight
studytonight.com › c › string-and-character-array.php
String and Character Arrays in C Language | Studytonight
Learn how to create a string, character arrays in C, string input and output and string functions in C.
🌐
Medium
medium.com › @divyasrdj › programming-in-c-arrays-strings-1695160875a3
Programming in C — Arrays & Strings | by Divya Stephen | Medium
June 16, 2025 - Even though Divya Stephen was entered in the above program, only “Divya” was stored in the name string. It’s because there was a space after Divya. ... We have used the code name instead of &name with scanf(). This is because name is a char array, and we know that array names decay to pointers in C.