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");
}
改檔名 ,把working_dir後面的路徑改成" . ",上working_dir下的都要!CodeBlocks執行後檢查下面的路徑是否為:C:\Users\randr\Desktop\freeglut\week15_robot\.
讀入一個字串
#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();//主要迴圈
}




沒有留言:
張貼留言