Advertisement
Kojima0502

text→binary OsakaWan

Sep 4th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 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,height,width,r_height;
  11.     float data;
  12.     char line[9];
  13.     if(argc!=5)
  14.     {
  15.         fprintf(stderr,"Usage: %s 5m_mesh_data.lem,5m_mesh_data.raw\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,"5mïWçÇÉfÅ[É^ÉtÉ@ÉCÉãñº.lem\n");
  23.             exit(1);
  24.         }
  25.    
  26.         if((fpo=fopen(argv[2],"wb"))==NULL)
  27.     {
  28.             fprintf(stderr,"5mïWçÇÉfÅ[É^ÉtÉ@ÉCÉã.raw\n");
  29.             exit(1);
  30.         }
  31.    
  32.         height=atoi(argv[3]);
  33.         width=atoi(argv[4]);
  34.         r_height=height※width/10;
  35.         for(i=0;i<r_height;i++)
  36.     {
  37.         fseek(fpi,i*82,SEEK_SET);
  38.        
  39.         for (j=0;j<10;j++)
  40.         {
  41.             fseek(fpi,8*j+i*82,SEEK_SET);
  42.             fgets(line, 9, fpi);
  43.             data=atof(line);
  44.            // printf("%f\n",data);
  45.             fwrite(&data,sizeof(float),1,fpo);
  46.         }
  47.     }
  48.    
  49.     fclose(fpi);
  50.     fclose(fpo);
  51.    
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement