If i use "if (cells->states == NULL)" it doesn't do anything, thus the malloc function should succeed.
The problem is in Array_Get: It can't return the value pointed to by the pointer
Printable View
If i use "if (cells->states == NULL)" it doesn't do anything, thus the malloc function should succeed.
The problem is in Array_Get: It can't return the value pointed to by the pointer
> memset(cells, 0, sizeof(*cells));
And this trashes the pointers to the memory you just allocated in the previous lines.
Just as we thought we were getting somewhere explaining arrays, you suddenly decide to enter a whole new race on a whole new horse.
Only this horse is a real buckaroo and you're in for a rough ride!
Yes I know, but I'm starting to feel better with pointers than with arrays. So memset is the bad guy? How can I undergo this?
memset the result of malloc, for the amount you asked for.
Or use calloc(), which achieves the same thing.
Wow! Now it works! Thanks for helping a newb!
Sorry, but Now, when I calculate and draw two times, it crashes at the very first Array_Get(prev_row, prev_item) position. What might it be?
PS: It doesn't really crash, but it says return value 3, and I don't have any exit(3) specified.
Most compilers come with a debugger.
The Visual Studio Express debugger is very nice.
But I remarked that AllocConsole etc. seems to be undefined?
EDIT: Solved. I wrote it all again (And tested at every step. It seemed as when I replace some pointers with real variables, it works. What's that? How can I prevent that?)