#include<stdio.h>
int main( int argc, char** argv)
{
FILE * fout=NULL;
fout = fopen("檔名.txt","+w");
printf( "Hello World\n");
fprintf( fout,"Hello World\n");
}
#include<stdio.h>
int main( int argc, char** argv )
{
/// FILE * fout=NULL;
/// fout = fopen("abc.txt", "w+");
/// printf( "Hello World\n" );
/// fprintf(fout, "Hello World\n" );
FILE * fin = NULL;
fin = fopen("abc.txt","r");
/// scanf( "%d",&n);
/// scanf( "%c",&c);
/// scanf( "%f",&f);
/// scanf( "%s",&line);
char line[100];
fscanf(fin, "%s",line);
printf("reading %s \n", line);
fscanf(fin, "%s",line);
printf("reading %s \n", line);
}
----------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <GL/glut.h>
float angle=0,diff=2;
void timer(int t)
{
glutTimerFunc(30,timer,t+1);
angle += diff;
if(angle>90)diff=-2;
if(angle<0) diff=+2;
glutPostRedisplay();
}
void display()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPushMatrix();///Step05-2
glutSolidTeapot( 0.3 );///身體
glPushMatrix();///Step05-2
glTranslatef(-0.3,0,0);
glRotatef(angle, 0,0,1);
glTranslatef(-0.3,0,0);
glutSolidTeapot( 0.3 );///左手臂, 但是,要用 T-R-T移位置
glPushMatrix();
glTranslatef(-0.3, 0,0);
glRotatef(angle, 0,0,1);
glTranslatef(-0.3, 0,0);
glutSolidTeapot( 0.3 );///左手肘
glPopMatrix();
glPopMatrix();///Step05-2
glPushMatrix();///Step05-2
glTranslatef(+0.3,0,0);
glRotatef(-angle, 0,0,1);
glTranslatef(+0.3,0,0);
glutSolidTeapot( 0.3 );///右手臂
glPushMatrix();///step05-3
glTranslatef(+0.3,0,0);
glRotatef(-angle, 0,0,1);
glTranslatef(+0.3,0,0);
glutSolidTeapot( 0.3 );///右手肘
glPopMatrix();///Step05-3
glPopMatrix();///Step05-2
glPopMatrix();///Step05-2
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit( &argc,argv);
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week15");
glutDisplayFunc(display);
glutTimerFunc(0,timer,0);
glutMainLoop();
}

沒有留言:
張貼留言