Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- int main(int argc,char *argv[])
- {
- /*****************************************************
- 1.Definition of Variables
- ******************************************************/
- FILE *fpr,*fpw; //file pointer for input&output file
- int no;
- float x,y,z;
- unsigned char id;
- int cnt;
- /*****************************************************
- 2.command line arguments processing
- ******************************************************/
- if(argc!=3)
- {
- fprintf(stderr,"Usage: %s (1)input_org.txt\n(2)write_xyz FILENAME\n",argv[0]);
- exit(1);
- }
- printf("OPEN FILE NAME:%s\n",argv[1]);
- /**********************************************************************************
- **********************************************************************************
- 4. FILE OPEN + Binary File Input
- **********************************************************************************
- *************************************************************************************/
- // open input file
- if((fpr=fopen(argv[1],"r"))==NULL)
- {
- printf("ファイルのオープンに失敗しました。プログラムを終了します。\n");
- exit(1);
- }
- //write file
- if((fpw=fopen(argv[2],"w"))==NULL)
- {
- fprintf(stderr,"DSM by GSI データファイル.raw\n");
- exit(1);
- }
- cnt = 0;
- /*****************************************************
- データの読み取り書き込み
- ******************************************************/
- /* データ処理 */
- while (fscanf(fpr, "%f %f %f %d", &x,&y,&z,&id) != EOF)
- {
- if(id==1)
- {
- cnt = 0;
- }
- else
- {
- cnt = cnt+1;
- }
- fprintf(fpw,"%f %f %f %d %d\n", x,y,z,id,cnt);
- }
- /* ファイル・クローズ */
- fclose(fpr);
- fclose(fpw);
- }
Advertisement
Add Comment
Please, Sign In to add comment