🌐
W3Schools
w3schools.com › java › java_arrays.asp
Java Arrays
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Server Java Syllabus Java Study Plan Java Interview Q&A Java Certificate ... Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value. To declare an array, define the variable type with square brackets [ ] : ... We have now declared a variable that holds an array of strings...
🌐
GeeksforGeeks
geeksforgeeks.org › c language › array-of-strings-in-c
Array of Strings in C - GeeksforGeeks
July 23, 2025 - We have 3 rows and 10 columns specified in our array of string which means that each string can be as long as 1o characters. But as we can see, there are many strings that takes less space than 10 but still allocated the same space due to the property of 2D array.
People also ask

Can I modify strings in an array of strings in C?
Yes, if you're using a 2D char array. But if you’re using string literals with pointers (char *arr[]), modifying them is unsafe.
🌐
wscubetech.com
wscubetech.com › resources › c-programming › array-of-strings
Array of Strings in C Language (With Examples)
How do I compare strings in an array?
Use strcmp(arr[i], arr[j]) to compare two strings. It returns 0 if the strings are equal.
🌐
wscubetech.com
wscubetech.com › resources › c-programming › array-of-strings
Array of Strings in C Language (With Examples)
How do I print all strings in an array?
Loop through with a for loop and use printf("%s", arr[i]); to print each string.
🌐
wscubetech.com
wscubetech.com › resources › c-programming › array-of-strings
Array of Strings in C Language (With Examples)
🌐
Whitman College
whitman.edu › mathematics › java_tutorial › java › nutsandbolts › arraysAndStrings.html
Arrays and Strings
At this point, enough memory has been allocated to contain the String references, but no memory has been allocated for the Strings themselves. If you attempted to access one of arrayOfStrings elements at this point, you would get a NullPointerException because the array is empty and contains no Strings and no String objects.
🌐
TutorialsPoint
tutorialspoint.com › home › cprogramming › c array of strings
C Array of Strings
June 10, 2012 - A string can be printed using the printf() function with %s format specifier. To print each string of an array of strings, you can use the for loop till the number of strings. In the following example, we are declaring, initializing, and printing an array of 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 - This means we can store the array's base address in the pointer and then traverse the entire array. So char* creates a pointer pointing to the string's base address. To declare an array of strings, we can create an array of these kinds of pointers. See the example below for a better illustration.
🌐
MathWorks
mathworks.com › matlab › language fundamentals › data types › characters and strings
Create String Arrays - MATLAB & Simulink
Create a string array containing multiple strings using the [] operator. str is a 2-by-3 string array that contains six strings. str = ["Mercury","Gemini","Apollo"; "Skylab","Skylab B","ISS"] str = 2×3 string "Mercury" "Gemini" "Apollo" "Skylab" "Skylab B" "ISS" Find the length of each string ...
🌐
W3Schools
w3schools.com › cs › cs_arrays.php
C# Arrays
We have now declared a variable that holds an array of strings.
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.

Find elsewhere
🌐
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!
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-string-array
Java String Array | DigitalOcean
August 3, 2022 - String array is very common in simple java programs, specially among beginners to java and to test some specific scenarios. Even java main method argument is string array - public static void main(String[] args). So today we will look into different aspects of java string array with example ...
🌐
Tealium
docs.tealium.com › server-side › attributes › data-types › arrays › arrays
Array of strings | About arrays | Tealium Docs
This example shows that the resulting attribute value is replaced, not appended to and that repeated values in the first array are removed. ... This enrichment removes all values from the array. ... This enrichment lowercases every value in the array. ... Sets an array of strings to a set of strings.
🌐
Awkward-array
awkward-array.org › doc › main › user-guide › how-to-create-strings.html
How to create arrays of strings — Awkward Array 2.9.0 documentation
['three', 'one', 'two', 'two', 'three', 'one', 'one', 'one'] --------- backend: cpu nbytes: 107 B type: 8 * categorical[type=string] Internally, the data now have an index that selects from a set of unique strings.
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java string array- tutorial with code examples
Java String Array- Tutorial With Code Examples
April 1, 2025 - This Tutorial Explains What is Java String contains() Method, its Usage, Syntax, and Various Scenarios with the help of Examples: This tutorial will help you to understand how to check a Java substring with respect to the main String with the help of contains() Java method. Upon going through this… ... Array Data Types – int Array, Double array, Array of Strings Etc.
🌐
LeetCode
leetcode.com › explore › learn › card › array-and-string
LeetCode's Array and String.
LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore.
🌐
NumPy
numpy.org › devdocs › user › basics.strings.html
Working with Arrays of Strings And Bytes — NumPy v2.5.dev0 Manual
Working with data loaded or memory-mapped from a data file, where one or more of the fields in the data is a string or bytestring, and the maximum length of the field is known ahead of time. This often is used for a name or label field. Using NumPy indexing and broadcasting with arrays of Python strings of unknown length, which may or may not have data defined for every value.
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › array-of-strings-in-cpp-5-different-ways-to-create
Array of Strings in C++ - GeeksforGeeks
October 3, 2025 - The push_back() function is then used to add another string, "container", to the vector. This shows the example of automatically resizable container for holding multiple strings. Above shown are the most preferred technique to create array of string but there are also some other ways as shown:
🌐
GeeksforGeeks
geeksforgeeks.org › java › string-arrays-in-java
String Arrays in Java - GeeksforGeeks
October 2, 2025 - ... // Java program to demonstrate various // methods to iterate over a string array public class GFG { public static void main(String[] args) { String[] arr = { "Apple", "Banana", "Orange" }; // First method for (String i : arr) { ...
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › how to create array of strings in python
How to Create Array of Strings in Python - Spark By {Examples}
December 20, 2024 - # Iterate array of stings using for loop # get the strings for str in arr_str: print(str) # Output: # Spark # by # examples · Alternatively, you can use a while loop to access each string present in the array. Using a while loop you can iterate a string as long as the condition is True.
🌐
CodeGym
codegym.cc › java blog › java arrays › string array in java
String Array in Java
May 11, 2023 - However Java has special tricks for it. If you’ve got an array of strings and need to add a new string to the end of your array, use the Arrays.copyOf method. This method creates a new array with one extra element, and then adds the new element to the end of the new array. Here's an example:
🌐
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 - In this declaration, array_name is the name of the array, and size is the number of strings the array can hold. For example, let's say you want to declare an array of 5 strings.