Spec: https://cs61c.org/sp22/projects/proj1/
TODO: describe what you did
Bugs I met:
- I used macro instead of the size info in the structure, which caused segfault when I called the function in other places. (Be careful of the constant?)
- I forgot to increase the numbe r of iterations.
- Strings are ending with \0. Printf %s prints everything until \0. When I iterated the buffer that collected the board characters, I tried to go through everything, which is unnecessary. (After assigning a larger string to a buffer, a new smaller string is saved in the same buffer with the data in the higher addresses not being overwritten.)
Things I learned:
- malloc: allocation from large -> small scale. free: free from small -> large scale.
- The usage of char**. (To save a array of a string)
- The way to access a member (char*) of char**. (char ** board; board[i]; // the i th member) (snake_t *snake; snake[i].tail_x = ; // access the member of snake_t struct)
- gdb: c - continue; info b - breakpoints info; del 1 - delete the 1st breakpoint.