Skip to content

Instantly share code, notes, and snippets.

@ruyut
Created March 28, 2019 05:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruyut/94233769717baecbdf381a36e6f24fc1 to your computer and use it in GitHub Desktop.
Save ruyut/94233769717baecbdf381a36e6f24fc1 to your computer and use it in GitHub Desktop.
//905-1
#include<stdlib.h>
#include<stdio.h>
int main() {
FILE *fi;//宣告檔案指標
double ss;//宣告雙精浮點數
fi = fopen("dnumber.dat", "w");//使用寫入的方式開啟檔名為dnumber.dat的檔案
do {
printf("請輸入浮點數:");
scanf("%lf", &ss);//輸入雙精浮點數
if (ss != -99.99)//如果變數不是-99.99的話
fprintf(fi, "%lf ", ss);//把數字寫入到檔案當中
} while (ss != -99.99);//如果變數不是-99.99的話就繼續重複執行
fclose(fi);//關閉檔案
system("PAUSE");//等待使用者按下任意按鍵
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment