Hi all,
this is a follow-up on my questions about segmentation fault that was generated when I tried to write data in an output file.
Thanks everybody that responded to that, I think that I have now located the error.
In a completely unrelated function, some matrix was filled "outside" of its indeces. The funny thing was that nothing happened here, but rather the program crashed later when I was trying to write data into a file.
Anyway, to prevent these memory issues in the future, I have some questions on malloc.
8<-------------------
float (* fun_matrix)[5];
.
.
.
*fun_matrix= malloc(10* sizeof(order_class);
fun_matrix[10][5]=3.14;
8<------------------
Is this correct use of malloc? Did I get the indeces right?
I read about using the "free" command to clear up memory when I am done. Is this necessary? If I don't use free, is the used memory still locked up after the program is finished? Can subsequent executions be affected?
Thanks again for all help.
Tor