There are two ways, static or dynamic. Which one to use depends on whether you know the number of rows or not.
Static
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define ROWS 10
#define COLUMNS 9
#define MAX_STRING_SIZE 256
int main(){
char table[ROWS][COLUMNS][MAX_STRING_SIZE];
//EXAMPLE OF USE
for(i=0; i<ROWS; i++)
for(j=0; j<COLUMNS; j++)
strcpy(table[i][j], "hi");
}
Dynamic
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define ROWS 10
#define COLUMNS 9
#define MAX_STRING_SIZE 256
int main(){
char ***table = calloc(ROWS, sizeof(char**));
int i, j;
for(i=0; i<ROWS; i++){
table[i] = calloc(COLUMNS, sizeof(char*));
for(j=0; j<COLUMNS; j++){
table[i][j] = calloc(MAX_STRING_SIZE, sizeof(char));
}
}
//FREE THE TABLE
for(i=0; i<ROWS; i++){
for(j=0; j<COLUMNS; j++){
fprintf(stderr, "%s, ", table[i][j]);
free(table[i][j]);
}
fprintf(stderr, "\n");
free(table[i]);
}
free(table);
}
Of course you need to check if the calloc calls return NULL. Allocating the strings with calloc ensures that the strings will be initialized with zeros. This algorithms will create 10 rows, with 9 columns being each column a string of 256 chars.