2021年5月31日 星期一

week15安安你好

 step01:

            Hello World

程式碼如下
#include <stdio.h>
int main(int argc,char**argv)
{

    FILE*fout=NULL;
    fout=fopen("08160050.txt","w+");

    printf("Hello World\n");
    fprintf(fout,"Hello World\n");
}

step02:
            改檔名 ,把working_dir後面的路徑改成"  . ",上working_dir下的都要!CodeBlocks執行後檢查下面的路徑是否為:C:\Users\randr\Desktop\freeglut\week15_robot\.


step03:

            讀入一個字串
程式碼如下:
#include <stdio.h>
int main(int argc,char**argv)
{

   /// FILE*fout=NULL;
    ///fout=fopen("08160050.txt","w+");

    ///printf("Hello World\n");
    ///fprintf(fout,"Hello World\n");

    FILE*fin=NULL;
    fin =fopen("08160050.txt","r");///開起step01和step02的檔案read

    char line[100];///step03 宣告一個字串
    fscanf(fin,"%s",line);
    printf("現在讀到的是 %s \n",line);

    fscanf(fin,"%s",line);///讀入一個字串
    printf("現在讀到的是 %s \n",line);///印出字串

}
step 04
            做一個茶壺

程式碼如下:
#include <GL/glut.h>
void display()
{


    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//清空


    glutSolidTeapot(0.3);//實心茶壺
    glutSwapBuffers();//交換兩倍的buffers
}

int main(int argc, char *argv[])//以前我們程式碼會寫 int main()
{
    glutInit(&argc, argv);//GULT初始設定
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);//顯示模式
    glutCreateWindow("08160520陳柏勻"); //(視窗的名稱)


    glutDisplayFunc(display);//等等要顯示的涵式

    glutMainLoop();//主要迴圈
}


沒有留言:

張貼留言

Week18期末作業(橘貓的跳舞熊熊)

 期末作業(橘貓的跳舞熊熊) 影片: https://youtu.be/R89tptMaQZw 程式碼: #include <opencv/highgui.h> #include <opencv/cv.h> #include <GL/glut.h...