→ doobee:謝 推 61.216.82.187 03/23
#include<stdio.h>
main()
{
FILE *f;
int yes=1;
long int N;
float D,H;
f=fopen("a:a1101.dat","w");
while(yes==1)
{
printf("enter N= "); scanf("%ld",&N);
printf("enter D= "); scanf("%f",&D);
printf("enter H= "); scanf("%f",&H);
printf("enter 1 to comtinue\n"); scanf("%d",&yes);
fprintf(f, "%ld %7.1f %7.1f\n", N,D,H);
}
fclose(f);
}
紅色ㄉ地方如果指定為int %d 在N過大ㄉ情況下會變負值
要看自己輸入ㄉ結果
可以用筆記本把 a:a1101.dat 打開
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.244.186
※ 編輯: thorstan1234 來自: 140.112.244.186 (03/23 16:00)