/* MAKEBDAT.C */ /* Create a data file for use with BFLIGHT.C */ /* The data file contains locations of various forces. */ /* The file also contains lift and weight and mass of the blimp. */ #include #include #include typedef struct { double xl,yl, xd,yd, xt,yt, ml,mw, mass; } DATASET; /* Data file uses this structure. */ main() { DATASET d; char fname[80]; FILE *fhandle; printf("File to use as specification data: "); scanf("%s",fname); printf("\n"); if((fhandle = fopen(fname,"w+")) == NULL) { printf("ERROR opening file -- %s\n",fname); exit(0); } /* Get data information from the user. */ printf("Enter all location data in meters. values are relative to center of mass.\n"); printf("Enter an x value then a y value with a space between.\n\n"); printf("Location of center of lift floating point (x) (y): "); scanf("%lf %lf\n",&d.xl,&d.yl); printf("%lf %lf\n",d.xl,d.yl); printf("\nLocation of center of drag: "); scanf("%lf %lf\n",&d.xd,&d.yd); printf("%lf %lf\n",d.xd,d.yd); printf("\nLocation of thrusters: "); scanf("%lf %lf\n",&d.xt,&d.yt); printf("%lf %lf\n",d.xt,d.yt); printf("\n\nEnter the lift force: "); scanf("%lf\n",&d.ml); printf("%lf\n",d.ml); printf("\nEnter the weight force: "); scanf("%lf\n",&d.mw); printf("%lf\n",d.mw); printf("\nEnter the mass (including the mass of the helium): "); scanf("%lf\n",&d.mass); printf("%lf\n",d.mass); /* write all of the data to the disk. */ fwrite(&d,sizeof(DATASET),1,fhandle); printf("FILE WRITTEN\n"); fcloseall(); }