www.pudn.com > c.rar > READNODE.C, change:1997-08-10,size:1138b


#include "stdio.h" 
#define MAX 10000 
void main() 
{ 
FILE *fp1,*fp2; 
float ver; 
int nodenum,t[14],i,j; 
char s1[80],s2[80]; 
float nodex[MAX],nodey[MAX],nodez[MAX]; 
printf("Please enter data filename:"); 
gets(s1); 
if((fp1=fopen(s1,"r"))==NULL){ 
	printf("\t\nCannot open the file or file not find!\n"); 
	exit(1); 
	} 
printf("Reading datas......\n"); 
fseek(fp1,23L,0); 
fscanf(fp1,"%d",&nodenum); 
for(i=0;i<=13;i++) 
fscanf(fp1,"%d",&t[i]); 
fscanf(fp1,"%f",&ver); 
for(i=0;i<=6;i++) 
fscanf(fp1,"%d",&t[i]); 
fscanf(fp1,"%f%f%f",&nodex[0],&nodey[0],&nodez[0]); 
fscanf(fp1,"%d%f%d%d",&t[0],&ver,&t[1],&t[2]); 
for(j=1;j<=nodenum-1;j++) 
{ 
for(i=0;i<=6;i++) 
fscanf(fp1,"%d",&t[i]); 
	{ 
	  fscanf(fp1,"%f%f%f",&nodex[j],&nodey[j],&nodez[j]); 
	  fscanf(fp1,"%d%f",&t[0],&ver); 
	  } 
} 
printf("Please input savedata filename:"); 
gets(s2); 
if((fp2=fopen(s2,"w"))==NULL){ 
	printf("\t\nCannot open the file!\n"); 
	exit(1); 
	} 
printf("\nSaving datas......\n"); 
for(j=0;j<=nodenum-1;j++) 
fprintf(fp2,"%e %e %e\n",nodex[j],nodey[j],nodez[j]); 
printf("\n\n\t\aProgram is over!\n"); 
printf("\t******************\n"); 
}