www.pudn.com > c.rar > READSAVE.C, change:1997-08-11,size:2696b


#include "stdio.h" 
#define MAX 10000 
void main() 
{ 
FILE *fp1,*fp2; 
FILE *fp3,*fp4; 
int d,d1; 
char ch0[10]; 
float sigma_max[4],sigma_min[4]; 
float *psigma_max,*psigma_min; 
float ver[50]; 
int nodenum,t[14],i,j; 
int num_node[4]; 
char ch,s1[80],s2[80],s3[80],s4[80]; 
float nodex[MAX],nodey[MAX],nodez[MAX]; 
int *p1; 
float *px,*py,*pz; 
px=nodex;py=nodey;pz=nodez; 
psigma_max=sigma_max;psigma_min=sigma_min; 
printf("Please enter ORIGINAL_data filename:"); 
gets(s1); 
if((fp1=fopen(s1,"r"))==NULL){ 
	printf("\t\nCannot open the file or file not find!\n"); 
	exit(1); 
	} 
printf("Please enter stressdata filename:"); 
gets(s3); 
if((fp3=fopen(s3,"r"))==NULL){ 
	printf("\t\nCannot open the file or file not find!\n"); 
	exit(1); 
	} 
printf("Reading datas......\n"); 
for(i=0;i<=18;i++) 
fscanf(fp1,"%c",&ch); 
fscanf(fp1,"%f%d",&ver[0],&nodenum); 
for(i=0;i<=13;i++) 
fscanf(fp1,"%d",&t[i]); 
fscanf(fp1,"%f",&ver[0]); 
for(i=0;i<=6;i++) 
fscanf(fp1,"%d",&t[i]); 
fscanf(fp1,"%f%f%f",&px[0],&py[0],&pz[0]); 
fscanf(fp1,"%d%f%d%d",&t[0],&ver[0],&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",&px[j],&py[j],&pz[j]); 
	  fscanf(fp1,"%d%f",&t[0],&ver[0]); 
	  } 
} 
printf("Please input STRESS_savedata filename:"); 
gets(s2); 
if((fp2=fopen(s2,"w"))==NULL){ 
	printf("\t\nCannot open the file!\n"); 
	exit(1); 
	} 
printf("Please input ELE_NODE_savedata filename:"); 
gets(s4); 
if((fp4=fopen(s4,"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",px[j],py[j],pz[j]); 
for(i=0;i<=7;i++) 
fscanf(fp1,"%d",&t[i]); 
for(i=0;i<=33;i++) 
fscanf(fp1,"%f",&ver[i]); 
fprintf(fp2,"******************************\n"); 
fprintf(fp4,"ELEMENT\tI\tJ\tK\tL\n"); 
fprintf(fp2,"NODENUM\tSIGMA_MAX\tSIGMA_MIN\n"); 
for(i=0;i<=833;i++) 
fscanf(fp3,"%c",&ch); 
for(i=0;i<=t[1]-1;i++) 
{ 
p1=num_node; 
fscanf(fp1,"%d",&t[4]); 
fprintf(fp4,"%d\t",t[4]); 
for(j=0;j<=3;j++) 
	{ 
	 fscanf(fp1,"%d",&p1[j]); 
	 fprintf(fp4,"%d\t",p1[j]); 
	 if(j==3)fprintf(fp4,"\n"); 
	 fscanf(fp3,"%d%d%s",&d,&d1,ch0); 
	 fscanf(fp3,"%f%f%f%f",&ver[0],&ver[1],&ver[2],&ver[3]); 
	 fscanf(fp3,"%f%f",&psigma_max[j],&psigma_min[j]); 
	 fscanf(fp3,"%f",&ver[4]); 
	 fprintf(fp2,"%-5d\t",p1[j]); 
	 fprintf(fp2,"%e\t%e\n",psigma_max[j],psigma_min[j]); 
	} 
fscanf(fp1,"%d%f%f%d%d%f",&t[2],&ver[0],&ver[1],&t[3],&t[4],&ver[2]); 
if(kbhit())if(getch()==27)break; 
} 
printf("\n\n\t\aProgram is over!\n"); 
printf("\t******************\n"); 
fclose(fp1); 
fclose(fp2); 
fclose(fp3); 
fclose(fp4); 
} 
/*******************************************/