第三个坑 C Primer Plus第六版 17.2程序释放链表bug
C Primer Plus是一本很好的C语言书,里面的代码丰富详细,对初学者的晋升有很大帮助,但问题在于代码也都是人编写的,出现bug也是很正常的。善于发现bug也是一种能力。
话不多说 实锤
下面是书中的源代码
#include <stdio.h>
#include <stdlib.h> /* has the malloc prototype */
#include <string.h> /* has the strcpy prototype */
#define TSIZE 45 /* size of array to hold title */
struct film {
char title[TSIZE];
int rating;
struct film * next; /* points to next struct in list */
};
char * s_gets(char