Advertisement
hasegawa

t2b

Oct 5th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.04 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>              
  3. #include <string.h>
  4.  
  5.  
  6.  
  7. int main(int argc,char*argv[])
  8. {
  9.     FILE *fpi,*fpo;            
  10.     int i,j,k,face,vertex,point;
  11.     float data;
  12.     char line[6];
  13.     if(argc!=6)
  14.     {
  15.         fprintf(stderr,"Usage: %s inputFILENAME.txt\n,outputFILENAME.bin\n",argv[0]);
  16.         exit(1);
  17.     }
  18.         printf("OPEN FILE NAME:%s\n",argv[1]);
  19.    
  20.         if((fpi=fopen(argv[1],"r"))==NULL)
  21.     {
  22.             fprintf(stderr,"Can not open\n");
  23.             exit(1);
  24.         }
  25.    
  26.         if((fpo=fopen(argv[2],"wb"))==NULL)
  27.     {
  28.             fprintf(stderr,"Can not open\n");
  29.             exit(1);
  30.         }
  31.    
  32.         face=atoi(argv[3]);
  33.         vertex=atoi(argv[4]);
  34.         point=atoi(argv[5]);
  35.         for(i=0;i<face;i++)
  36.     {
  37.         //fseek(fpi,i*17,SEEK_SET);
  38.        
  39.         for (j=0;j<vertex;j++)
  40.         {
  41.             for(k=0;k<point;k++)
  42.             {
  43.                 fseek(fpi,5*k+j*17+i*68,SEEK_SET);
  44.                 fgets(line, 6, fpi);
  45.                 data=atof(line);
  46.                         printf("%f\n",data);
  47.                 fwrite(&data,sizeof(float),1,fpo);
  48.             }
  49.         }
  50.     }
  51.    
  52.     fclose(fpi);
  53.     fclose(fpo);
  54.    
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement