c語言中,為什么以下程序直接按”Enter“也就是回車程序不結束?


 1 /*************************************************************************
 2     > File Name: system.c
 3     > Author: Mr.Yang
 4     > Purpose:演示system()函數
 5     > Created Time: 2017年05月19日 星期五 19時29分17秒
 6  ************************************************************************/
 7 
 8 #include <stdio.h>
 9 #include <stdlib.h>
10 
11 char input[40];
12 
13 int main(void)
14 {
15         while(1)
16         {
17                 printf("Input the desire system command,blank to exit:");
18                 fgets(input,40,stdin);
19                 if(input[0] == '\0')//檢測是否是空字符,如果是,直接退出程序,但在linux上運行不退出?
20                 {
21                         exit(0);
22                 }
23                 else
24                 {
25                         system(input);
26                 }
27         }
28 
29         return 0;
30 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM