I am starting and I am doing some practice to learn something.
I have work on dynamic memory allocation with strings and pointers I have this structure:
fact_table = malloc (sizeof (struct fact_entry));
Why? In the first case, I am only reserving memory for one line, is it true? Why is no division fault generating error?
Correct but bad code does not mean an accident You will write on the memory that you were not expected to allocate. But this is your memory! Depending on the implementation, a page size block of malloc
may be allocated. This is likely to mean 4096 bytes. If you can afford it may crash when you overwrite it or if you have an allocation which comes from the pages you see problems. Second, why can I fill in the third column? I memory can not assign .. I do not know that I can do to refer to each row, because I have a strait with the pointer in a loop ... and I do not know how to define iterations malloc .
Not sure I follow them. You can allocate all the memory to one single maulock at one time. Then manually loop to properly address str_fact in that block of memory, but it is unnecessarily complicated, however, means that you have only one award was given by Aiomo answer right way.
Comments
Post a Comment