Advertisement
d10070dd

text2binary-points

Oct 24th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 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.     float x,y,z;
  8.     char point[4];
  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],"wb"))==NULL)
  20.     {
  21.         printf("The file can't be opened. The program is exit.\n");
  22.  
  23.         return 0;
  24.     }
  25.  
  26.     while(fscanf(fpi,"%f %f %f",&x,&y,&z)!=EOF)
  27.         {
  28.             printf("%f %f %f\n",x,y,z);
  29.             fwrite(&x,sizeof(float),1,fpo);
  30.             fwrite(&y,sizeof(float),1,fpo);
  31.             fwrite(&z,sizeof(float),1,fpo);
  32.         }
  33.  
  34.         fclose(fpi);
  35.         fclose(fpo);
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement