ait-survey

org2xyz

Nov 11th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.26 KB | None | 0 0
  1. /***************************************************************************:::
  2.  org2xyz
  3.  
  4.  DSM floatデータ型で格納
  5.  read
  6.  2008/1/10
  7.  made by Yoshiyuki Yamamoto
  8.  ver1.1 2009/3/7
  9.  *******************************************************************************/
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <math.h>
  14.  
  15. int main(int argc,char *argv[])
  16. {
  17.        
  18.     /*****************************************************
  19.          1.Definition of Variables
  20.          ******************************************************/
  21.     FILE *fpr,*fpw;  //file pointer for input&output file
  22.     int no;
  23.     float x,y,z;
  24.  
  25.        
  26.        
  27.     /*****************************************************
  28.          2.command line arguments processing
  29.          ******************************************************/
  30.     if(argc!=3)
  31.     {
  32.             fprintf(stderr,"Usage: %s (1)input_org.txt\n(2)write_xyz FILENAME\n",argv[0]);
  33.             exit(1);
  34.         }
  35.         printf("OPEN FILE NAME:%s\n",argv[1]);
  36.        
  37.         /**********************************************************************************
  38.          **********************************************************************************
  39.          4.  FILE OPEN + Binary File Input
  40.          **********************************************************************************
  41.          *************************************************************************************/
  42.        
  43.         // open input file
  44.         if((fpr=fopen(argv[1],"r"))==NULL)
  45.         {
  46.             printf("ファイルのオープンに失敗しました。プログラムを終了します。\n");
  47.             exit(1);
  48.         }
  49.        
  50.         //write file
  51.         if((fpw=fopen(argv[2],"w"))==NULL)
  52.         {
  53.                 fprintf(stderr,"DSM by GSI データファイル.raw\n");
  54.                 exit(1);
  55.         }
  56.        
  57.     /*****************************************************
  58.          データの読み取り書き込み
  59.          ******************************************************/
  60.     /* データ処理 */
  61.         while (fscanf(fpr, "%d,%f,%f,%f", &no,&x,&y,&z) != EOF)
  62.         {
  63.             fprintf(fpw,"%f %f %f\n",x,y,z);
  64.             //printf("x:%f y:%f z:%f\n", x,y,z);
  65.         }
  66.  
  67.     /* ファイル・クローズ */
  68.         fclose(fpr);
  69.         fclose(fpw);
  70. }
Advertisement
Add Comment
Please, Sign In to add comment