I have a structure defined as a char** array containing strings. I don't know how to run printf on its contents.
#include <stdio.h> #include <string.h> #include <stdlib.h> #ifndef STRUCT_STRING_ARRAY #define STRUCT_STRING_ARRAY typedef struct s_string_array { int size; char** array; } string_array; #endif void my_print_words_array(string_array* param_1) { int len = param_1->size; char **d = param_1->array; for(int i = 0 ; i < len;i++){ printf("%s\n", d[i]); } } int main(){ struct s_string_array *d; d->size = 2; char **my_arr = (char *[]){"hello", "world"};//this init is fine d->array = my_arr; my_print_words_array(d); return 0 ; } The main function gives me segfault error. What's wrong?
struct s_string_array *d;