2d character array in c
- how to use char array in c
- how to take char array input in c++
- how to char array in c++
- how to print char array in c
Print char array in c
Character array in c!
Array of Strings in C
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). It is used to store multiple strings in a single array.
Let’s take a look at an example:
An array of strings allows you to store and manipulate text in C.
Syntax of Array of Strings
chararr_name[r][m] = {s1, s2, …., sn};
Here,
- arr_name: Name of the variable.
- r: Maximum number of strings to be stored in the array
- m: Maximum number of character values that can be stored in each string.
- s1, s2, …., sn: Strings to be stored.
Invalid Operations in Arrays of Strings
We can’t directly change or assign the values to an array of strings in C.
Example:
char arr[3][10] = {“Geek”, “Geeks”, “Geekfor”};
arr[0] = “GFG”;
// This will give an Error that says assignment to expression with an array type.
To change values we can use strcpy()function in C:
strcpy(arr[0],”GFG”)
how to initialize char array in c
how to return char array in c