2018年5月25日 星期五

week13-04160453

1.寫檔讀檔

a.開一個Empty file

  另存檔案

輸入
#include <stdio.h>
int main()
{
    FILE * fout = fopen("output.txt","w+");
    fprintf(fout,"Hello world\n");
}


開一個glut project

刪掉不要的東西



1.宣告檔案的指標,一開始是空的
(FILE * fout=NULL;)
2.用鍵盤存檔
void keyboard(unsigned char key, int x, int y)
{
    if(key=='s' || key=='S' || key=='w' || key=='W'){
        if(fout==NULL) fout=fopen("output.txt", "w+");
        
       
        printf("%.3f %.3f %.3f\n", angle,angle2,angle3);
        fprintf(fout, "%.3f %.3f %.3f\n", angle,angle2,angle3);
    }
}








沒有留言:

張貼留言