Advertisement
hasegawa

☆text2text-vtk-points2

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