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
๐ŸŒ
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).
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ strings-in-c
Strings in C - GeeksforGeeks
November 14, 2025 - This null character marks the end of the string and is essential for proper string manipulation. Unlike many modern languages, C does not have a built-in string data type. Instead, strings are implemented as arrays of char.
๐ŸŒ
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.
๐ŸŒ
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).
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c++ โ€บ arrays-and-strings-in-c
Arrays and Strings in C++ - GeeksforGeeks
July 12, 2025 - For example it is declared as: char str[] = "GeeksforGeeks" Below is the program to illustrate the traversal in the string: ... // C++ program to illustrate the // traversal of string #include "iostream" using namespace std; // Function to ...
Top answer
1 of 15
304

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
250

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.

๐ŸŒ
OverIQ
overiq.com โ€บ c-programming-101 โ€บ array-of-strings-in-c
Array of Strings in C - C Programming Tutorial - OverIQ.com
What is an Array of Strings? # 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โ€ฆ
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ strings-and-arrays-interview-questions-c-programming
C Strings and Arrays Interview Questions - GeeksforGeeks
August 23, 2025 - An array in C is a collection of elements of the same data type stored in contiguous memory locations. Arrays allow efficient indexed access using zero-based indexing. In C, a string is simply a character array terminated with a special null ...
Find elsewhere
๐ŸŒ
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....
๐ŸŒ
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. The string is a one-dimensional array of characters terminated with the null character.
๐ŸŒ
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.
๐ŸŒ
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 - A string array or an array of strings in C is a two-dimensional array that contains strings as elements. They help in manipulating textual data with ease.
๐ŸŒ
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!
๐ŸŒ
SkillVertex
skillvertex.com โ€บ blog โ€บ array-of-strings-in-c
Array Of Strings In C -
May 10, 2024 - An array of strings in C, often referred to as a โ€œtwo-dimensional array of character types,โ€ is essentially an array of arrays of characters. Each element in the first dimension is a string (which is an array of characters), and you can ...
๐ŸŒ
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; }
๐ŸŒ
Log2Base2
log2base2.com โ€บ C โ€บ string โ€บ array-of-string.html
Array of strings in c
#include<stdio.h> int main() { /* *total 5 strings *each string can at max 20 char long. */ char subject[5][20]={"Tamil","English","Maths","Science","Social Science"}; int i; //printing each string for(i = 0; i < 5; i++) printf("%s\n",subject[i]); return 0; } Run it ยท Getting array of string input from the user and print it.
๐ŸŒ
TheLinuxCode
thelinuxcode.com โ€บ home โ€บ array of strings in c
Array of Strings in C โ€“ TheLinuxCode
May 20, 2025 - This null terminator is crucial โ€“ it tells C functions where the string ends. Without it, functions like printf() would continue reading memory beyond the intended string until they happened to encounter a zero byte. In C, you can create arrays of strings using several approaches, each with its own advantages and trade-offs.
๐ŸŒ
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.