logo

How to declare an array of strings in C

#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char* argv[]) { char array[3][50]; // string copy strcpy(array[0], "Hello world"); strcpy(array[1], "test"); strcpy(array[2], "1234"); printf("Strings are: \n%s\n%s\n%s\n", array[0], array[1], array[2]); return 0; }
Course thumb

The C programming language made simple