//Beginning of main(void) int main(void) { //Initializes variables struct holeStruct holeData[MAX_HOLES]; struct dimenssionStruct dimenssion; struct dimenssionStruct*dimenPtr=&dimenssion; char label1[50]; char label2[50]; float inputDepth=0; //Holds input indicating if user wants to run or quit the program int mainChoice=0; //This hold the value (as returned by scanf()) indicating number of assignments made int validDepth=0; int soilChoice=0; int readResult=0; //result from readData function is stored in readResult var. readResult=readData(holeData,label1,label2); switch(readResult) { case 0: { //If readResult=0, below code is executed calcDimen(holeData,dimenPtr); calcHoleCoord(holeData,dimenPtr); initGraphics(dimenPtr); showAllData(holeData,label1,label2,dimenPtr); setcolor(WHITE); outtextxy(2,2,"Enter a depth in the console to see the soil information at that depth here."); /*This do..while loop calls the routines inside it as long as user does not decide to quit the program*/ do{ mainChoice=displayMainMenu(); if(mainChoice==1) { do { printf("\nEnter a depth (in meters):"); fflush(stdin); validDepth=scanf("%f",&inputDepth); }while(validDepth==0); inputDepth=fabs(inputDepth); soilChoice=displaySoilMenu(); processPrint(holeData,inputDepth,label1,label2,dimenPtr,soilChoice,1); } }while(mainChoice!=2); break; } case 1: { printf("You have chosen to exit the program because data from the file could not be read.\n Press Enter to exit."); break; } default: { printf("\nUnexpected error occoured in main(void)\n"); break; } } return readResult; }
//Beginning of main(void) int main(void) { //Initializes variables struct hole holeData[MAX_HOLES]; struct graphicWindow gfxWin; struct soil_palette soilPalette; char label1[LABEL_LENGTH]; char label2[LABEL_LENGTH]; float inputDepth=0; //Holds input indicating if user wants to run or quit the program int mainChoice=0; //This hold the value (as returned by scanf()) indicating number of assignments made int validDepth=0; int readResult=0; //result from readData function is stored in readResult var. readResult=readData(holeData,label1,label2); switch(readResult) { case 0: { //If readResult=0, below code is executed calcDimen(holeData,&gfxWin); initGraphics(&gfxWin,&soilPalette); calcHoleCoord(holeData,&gfxWin); showAllData(holeData,label1,label2,&gfxWin); /*This do..while loop calls the routines inside it as long as user does not decide to quit the program*/ do{ mainChoice=displayMainMenu(); if(mainChoice==1) { do { printf("\nEnter a depth (in meters):"); fflush(stdin); validDepth=scanf("%f",&inputDepth); }while(validDepth==0); inputDepth=fabs(inputDepth); processInput(holeData,soilPalette,inputDepth,label1,label2,&gfxWin,displaySoilMenu(),1); } }while(mainChoice!=2); break; } case 1: { printf("You have chosen to exit the program because data from the file could not be read.\n Press Enter to exit."); break; } default: { printf("\nUnexpected error occoured in main(void)\n"); break; } } return readResult; }