#include <stdio.h>///使用standard輸入輸出IO
int main()
{
FILE * fout=fopen("output.txt", "w+");
///FILE * 檔案指標 fout
/// 檔案 file
/// open開啟
/// "要開啟的檔名","w+"表示要寫/+檔案
printf("Hellow world\n");
fprintf(fout,"Hello world\n");
}
int n;
scanf("%d", &n);///只是故意讓程式卡住,檔案就沒正常關閉
///檔案長度就會是0
#include <stdio.h>
FILE * fout=NULL;///檔案一開始是空的 NULL
float angle=0;
int oldX=0;
void mouse(int button, int state, int x, int y)
{
oldX=x;
}
void motion(int x, int y)///用 mouse motion 來改關節 angle
{
angle+=x-oldX;///角度稍微增減,以前教過把大象放到冰箱去的程式碼
oldX=x;///把舊的更新成新的
if(fout==NULL)///一開始是空指標,所以會進來 if(....)
{
fout = fopen("output.txt", "w+");///開檔
}///之後就不再是空指標了
fprintf(fout, "%.3f\n",angle)///把角度印到檔案裡
printf("%.3f\n",angle);///把角度印出來
glutPostRedisplay();///重畫畫面
}
→先用滑鼠作出想要的動畫,在按空白鍵跑出剛剛的動畫




沒有留言:
張貼留言