Hi, I have the below program...
...and one of the irritating problems that I'm getting is that when I try to execute the program(it compiles without a hitch), it crashes. I narrowed the problem down to the first use of "structure_array", but I'm not sure how to fix it. Thanks in advance.Code:// structure_arrays.c: #include <stdio.h> #include <string.h> struct index { int page; char *title; }; int main() { int i = 0; struct index *structure_array[10]; for(; i < 10; i++) { structure_array[i] -> page = i * 10; strncpy(structure_array[i] -> title, (char *)(i * 2), (size_t)2); } for(i = 0; i < 10; i++) printf("%s %d\n", structure_array[i] -> title, structure_array[i] -> page); return 0; }




Reply With Quote