Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- int main(int argc,char *argv[])
- {
- FILE *fpi,*fpo;
- int i,j,k,nums/*,face,vertex,point*/;
- int data;
- int id,x,y,z;
- int *file1;
- char line[4];
- if(argc!=4)
- {
- fprintf(stderr,"Usage: %s 5m_mesh_data.lem,5m_mesh_data.raw\n",argv[0]);
- exit(1);
- }
- printf("OPEN FILE NAME:%s\n",argv[1]);
- if((fpi=fopen(argv[1],"r"))==NULL)
- {
- fprintf(stderr,"Can not open\n");
- exit(1);
- }
- if((fpo=fopen(argv[2],"wb"))==NULL)
- {
- fprintf(stderr,"Can not open\n");
- exit(1);
- }
- nums=atoi(argv[3]);
- file1= (int *)malloc(nums*3*sizeof(int));
- //vertex=atoi(argv[4]);
- //point=atoi(argv[5]);
- /* for(i=0;i<nums;i++)
- {
- for (j=0;j<3;j++)
- {
- //for (k=0;k<point;k++)
- //{
- //fseek(fpi,6*k+j*20+i*68,SEEK_SET);
- fseek(fpi,j*3+i*11,SEEK_SET);
- fgets(line, 4, fpi);
- data=atoi(line);
- //printf("%d\n",data);
- fwrite(&data,sizeof(int),1,fpo);
- //fseek(fpi,2,SEEK_CUR);
- //}
- }
- }
- */
- int count=0;
- while (fscanf(fpi,"%d %d %d %d ",&id, &x, &y, &z )!= EOF)
- {
- file1[3*count]=x;
- file1[3*count+1]=y;
- file1[3*count+2]=z;
- count=count+1;
- }
- fwrite(file1,sizeof(int),nums*3,fpo);
- fclose(fpi);
- fclose(fpo);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement