Advertisement
hasegawa

imeco_txt(Six-digit)/変更

Feb 28th, 2014
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int     main(int argc, char *argv[])
  4. {
  5.     //Decralation of variables
  6.     FILE *fpi,*fpo;
  7.     int ix,iy,a;
  8.     float x,y,z,b,c,d;
  9.    
  10.     //Open CSV file
  11.     if((fpi=fopen(argv[1],"r"))==NULL)
  12.     {
  13.         printf ("The file can't be opened. The program is exit.\n");
  14.        
  15.         return 0;
  16.     }
  17.    
  18.     //Open VTK file for save
  19.     if((fpo=fopen(argv[2],"w"))==NULL)
  20.     {
  21.         printf("The file can't be opened. The program is exit.\n");
  22.        
  23.         return 0;
  24.     }
  25.    
  26.    
  27.     //count how many lines
  28.     /*
  29.      while((c=fgetc(fpi))!=EOF)
  30.      {
  31.      if(c=='\n')
  32.      newline_count++;
  33.      }
  34.      */
  35.    
  36.     while(fscanf(fpi,"%d,%f,%f,%f",&a,&x,&y,&z)!=EOF)
  37.     {
  38.         ix=(int)((x+28000)-1);
  39.         iy=(int)((-139500-y)-1);
  40.         //printf("%d%d\n",ix,iy);
  41.        
  42.         fprintf(fpo,"%d %d %f %f %f\n",ix,iy,x,y,z);
  43.        
  44.     }
  45.    
  46.    
  47.     fclose(fpi);
  48.     fclose(fpo);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement