Advertisement
hasegawa

t2b-points

Feb 14th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.99 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5.  
  6. int main(int argc,char *argv[])
  7. {
  8.         FILE *fpi,*fpo;
  9.         float x,y,z;
  10.         int r,g,b;
  11.        
  12.        
  13.        
  14.        
  15.  
  16.         if(argc!=3)
  17.         {
  18.                 fprintf(stderr,"Usage: %s 5m_mesh_data.lem,5m_mesh_data.raw\n",argv[0]);
  19.                 exit(1);
  20.         }
  21.         printf("OPEN FILE NAME:%s\n",argv[1]);
  22.  
  23.         if((fpi=fopen(argv[1],"r"))==NULL)
  24.         {
  25.                 fprintf(stderr,"Can not open\n");
  26.                 exit(1);
  27.         }
  28.  
  29.         if((fpo=fopen(argv[2],"wb"))==NULL)
  30.         {
  31.                 fprintf(stderr,"Can not open\n");
  32.                 exit(1);
  33.         }
  34.  
  35.          
  36.  
  37.        while (fscanf(fpi,"%f %f %f %d %d %d",&x,&y,&z,&r,&g,&b)!= EOF)      
  38.        {
  39.          printf("%f %f %f %d %d %d\n",x,y,z,r,g,b);
  40.  
  41.          fwrite(&x,sizeof(float), 1,fpo);
  42.          fwrite(&y,sizeof(float),1,fpo);
  43.          fwrite(&z,sizeof(float),1,fpo);
  44.  
  45.        }
  46.  
  47.     fclose(fpi);
  48.     fclose(fpo);
  49.    
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement