//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; }
//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; }
int main(int argc, char *argv[]) { int portno,map_id; pthread_t receive_connection_thread; int receive_t; portno=atoi(argv[1]); char usertext[10]; system("setterm -term linux -back green -fore white -bold on -clear"); //system("gnome-terminal "); //gotoxy(50,50); fflush(stdout); clrScreen(); printCenter("Max No. of Players : "); scanf("%d",&max_players); clrScreen(); printCenter("No. Of Automatic Commandos : "); scanf("%d",&auto_commando_count); clrScreen(); printCenter("No.Of Automatic ALiens : "); scanf("%d",&auto_alien_count); printCenter(" Choose Arena\n"); printCenter("******************\n"); printCenter("1 : Forest_War\n"); printCenter("2 : Nuke_Alien\n"); printCenter("3 : Mountain_Comm\n"); printCenter("4 : Mission_Earth\n"); printCenter("5 : Collapse_CA\n"); printCenter("Your Choice : "); scanf("%d",&map_id); clrScreen(); initializeGame(map_id); serverInit(portno); printCenter(" *********The Game Begins Now*******\n"); printCenter(" Server Established \n"); printCenter("Waiting For Incomming Connections...\n"); //timer(); //change pthread_create(&receive_connection_thread,NULL,receiveIncomingConnections,(void *)&receive_t); //receiveIncomingConnections(); while(1) { printCenter("Press x to Shutdown Server : "); scanf("%s",usertext); if(strcmp(usertext,"q")==0) { system("setterm -default"); system("clear"); printf("All Connections Terminated\n"); printf("Server ShutDown\n"); showAllData(-1); shutDownServer(); //exit(0); } else { printCenter("Please enter x to quit :\n"); } } }