In C, an array of strings is simply an array of character arrays. Here is an example of how to create and use an array of strings:
```
#include <stdio.h>
#include <string.h>
int main() {
char strings[3][20] = {"Hello", "world", "!"}; // Create an array of strings
for (int i = 0; i < 3; i++) {
printf("%s\n", strings[i]); // Print each string
}
return 0;
}
```
In this example, we create an array of three strings, each with a maximum length of 20 characters. We initialize the strings with some sample text.
To access an individual string in the array, we use two sets of square brackets. The first set of brackets specifies the index of the string in the array, and the second set of brackets specifies the index of a character within the string. For example, `strings[0]` refers to the first string in the array, and `strings[0][0]` refers to the first character in that string.
In the example, we use a `for` loop to print each string in the array using the `%s` format specifier in the `printf()` function.
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc