開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Linux
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
無
問題(Question):
while內條件式無法成立
餵入的資料(Input):
while(sort_list->data)
預期的正確結果(Expected Output):
當不輸入資料,直接按下ENTER鍵時應該跳出do while迴圈
錯誤結果(Wrong Output):
do while行程無線迴圈
程式碼(Code):(請善用置底文網頁, 記得排版)
小弟欲輸入各個數字,並按下ENTER鍵後,離開程
typedef struct _list{
int data;
struct _list *next;
}list;
int main(int argc,char *argv[])
{
int input=0;
char *buffer=(char *)malloc(5);
list *sort_list;
do{
list *sort_list=(list *)malloc(sizeof(list));
sort_list->next=NULL;
printf("Please input your member to sort: ");
fgets(buffer,5,stdin);
sort_list->data=(atoi)(buffer);
printf("%d\n",sort_list->data);
} while (sort_list->data);
free(buffer);
free(sort_list);
}
補充說明(Supplement):