2019年5月17日 星期五

0517 week13

1.
開專案 20次 Hello Word


#include <stdio.h>
FILE * fout=NULL;  ///宣告 檔案指標 變數
int main()
{
    fout = fopen("filename.txt", "w+");   ///開檔案
    for(int i=0; i<20; i++){
        fprintf(fout, "Hello Word\n");
    }



輸入執行後不會直接出現在Codeblock
而是出現在專案儲存的資料夾中




2.

#include <stdio.h>
FILE * fout=NULL;  ///宣告 檔案指標 變數
float angle[20];
int main()
{
    //fout = fopen("motion.txt", "w+"); ///開檔案
    for(int i=0; i<20; i++){
        printf("%.1f ", angle[i]);
    }
}





把檔案改成存到桌面的資料夾

#include <stdio.h>
FILE * fout=NULL;  ///宣告 檔案指標 變數
float angle[20];
int main()
{
    fout = fopen("motion.txt", "w+"); ///開檔案
    for(int i=0; i<20; i++){
        fprintf( fout,"%.1f ", angle[i]);
    }
}







沒有留言:

張貼留言