#include #include #include #include #include #include #include //macros #define LOCATE(r, c) GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo);csbiInfo.dwCursorPosition.X = c;csbiInfo.dwCursorPosition.Y = r; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), csbiInfo.dwCursorPosition); using namespace std; //prototyping void paintMenu(), getChoice(); void car(string carName); void paintCarMenu(string carName), getCarChoice(); void toScreen(string file); //global varable char choice; int carChoice; vector option; CONSOLE_SCREEN_BUFFER_INFO csbiInfo; int main() { do { paintMenu(); getChoice(); }while(choice != '0'); system("CLS"); return 0; } void paintMenu() { system("CLS"); LOCATE(0,35); puts("MAIN MENU"); LOCATE(2,0); puts("\t1. Cars"); puts("\t2. Jobs"); puts("\t3. Programs"); puts("\n\r\t0. Quit"); LOCATE(23,0); printf("Enter your choice (0,1,2,3) =>"); } void getChoice() { scanf("%c",&choice); switch(choice) { case '1' : car(""); break; //case '2' : jobs(); break; //case '3' : programs(); break; case '0' : break; default : LOCATE(23, 40); printf("Invalid Entry\n\r"); system("PAUSE"); } fflush(stdin); } void car(string carName) { do { paintCarMenu(carName); getCarChoice(); }while(carChoice != '0'); system("CLS"); } void paintCarMenu(string carName) { option.clear(); string line; system("CLS"); LOCATE(0,35); ifstream carList; if(carName == "") { puts("Car Menu"); carList.open("car"); } else { cout << carName << " Menu"; carList.open(carName.c_str()); } LOCATE(1,0); for(int k = 1; !carList.eof(); k++) { getline(carList,line); //gets one line from text file as String if(line[0] == '_') { toScreen(carName); return; } //printf("\t%i. %s\n\r",k,line); cout << "\n\r\t" << k << " " << line; option.push_back(line); } puts("\n\n\r\t0. Quit"); LOCATE(23,0); printf("Enter your choice =>"); carList.close(); } void toScreen(string fileName) { LOCATE(0,35) cout << fileName; LOCATE(1,0); string line; ifstream file; file.open(fileName.c_str()); while(!file.eof()) { getline(file,line); cout << "\n\r"; cout << line; } } void getCarChoice() { cin.ignore(); fflush(stdin); scanf("%i",&carChoice); for( int j = 0; j < option.size(); j++) { if( carChoice == '0') { break; } else if(carChoice == j + 1) { cout << " i get here " << option.at(j); car(option.at(j)); return; } } { LOCATE(23, 40); printf("Invalid Entry\n\r"); system("PAUSE"); //getCarChoice(); //break; } fflush(stdin); }