关于C的一个简单有关问题

关于C的一个简单问题
这是c primer plus 上的一个例子。其中 while(gets(input) != NULL && input[0] != '\0'), 本应该是遇到空行输入的时候退出循环,但是我在VS2010上运行。。为神马不退出。。。。好纠结。源代码如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TSIZE 45
struct film{
char title[TSIZE];
int rating;
struct film *next;
};

int main(void)
{
struct film * head = NULL;
struct film * prev, * current;
char input[TSIZE];

puts("Enter first movie title:");
while(puts(input) != NULL && input[0] != '\0')
{
current = (struct film *)malloc(sizeof(struct film));
if(head == NULL)
head = current;
else
prev->next = current;
current->next = NULL;
strcpy(current->title,input);
puts("Enter your rating<0-10>:");
scanf("%d",&current->rating);
while(getchar()!='\n')
continue;
puts("Enter next movie title (empty line to stop):");
prev = current;
}

  if(head == NULL)
  printf("No data entered.");
  else
  printf("Here is te movie list:\n");
  current = head;
  while(current != NULL)
  {
  printf("Movie: %s Rating: %d \n",current->title,current->rating);
  current = current->next;
  }
   
  current = head;
  while(current != NULL)
  {
  free(current);
  current = current->next;
  }
printf("bye!\n");

return 0 ;
}

追加个问题:下面这样的释放内存的代码对么?当释放了current以后,current指向的空间就没了,current->是不是就不对了?
  current = head;
  while(current != NULL)
  {
  free(current);
  current = current->next;
  }


------解决方案--------------------
不要使用
while (条件)
更不要使用
while (组合条件)
要使用
while (1) {
 if (条件1) break;
 //...
 if (条件2) continue;
 //...
 if (条件3) return;
 //...
}
因为前两种写法在语言表达意思的层面上有二义性,只有第三种才忠实反映了程序流的实际情况。
典型如:
下面两段的语义都是当文件未结束时读字符
whlie (!feof(f)) {
 a=fgetc(f);
 //...
 b=fgetc(f);//可能此时已经feof了!
 //...
}
而这样写就没有问题:
whlie (1) {
 a=fgetc(f);
 if (feof(f)) break;
 //...
 b=fgetc(f);
 if (feof(f)) break;
 //...
}
类似的例子还可以举很多。

理论上free不改变指针指向的数据内容。
但就怕free后操作系统切换到其它线程或进程malloc重新占用并修改了指针指向的数据内容,随后切换回来的时候
执行current = current->next就可能出错了。