Valgrind Error when creating an array of linked lists (for Hash Table Chaining)
问题 As an overview, I'm trying to create a battleship-like game in C, where ships are placed on a field. Here is the error I am getting: ==11147== Invalid write of size 8 ==11147== at 0x400786: MakeField (battleship.c:34) ==11147== Address 0x8 is not stack'd, malloc'd or (recently) free'd Here is the relevant code: struct piece{ int x; int y; int direction; int length; char name; }; struct node{ struct piece boat; struct node *next; }; struct field{ int numBoats; struct node *array[numRows]; };