Hey guys, thanks for viewing my problem,, i am currently working on a program and i am trying to input a menu to run with a template i have i am having trouble looping the menu with the template the program is an X,Y plotter i have a template up and running but i just cant get the menu to function with the template some help will be greatley appreciated or if somone could teach me step's here it goes: The template Code: #include <iostream> #include <stdio.h> #include <fstream> using namespace std; int row = 0; int col = 0; char Array [21][75]; void Reset(){ // the initilize function call it like this when you need it Reset(); for (row = 0; row < 21; ++row){ for (col = 0; col < 75; ++col) Array[row][col] = '-'; col = 0; } }; void Display(){ // Displays the graph call it like this when you need it Display(); for (row = 21; row > 0; --row){ for (col = 0; col < 75; ++col) cout << Array[row][col]; col = 0; cout << "\n"; } } void selectfile(){ // lets them select a file call it like this when you need it selectfile(); system("cls"); ifstream myfile; int Selection; // read a input from the user and put in either // this myfile.open("circle.txt"); // or this myfile.open("square.txt"); while(!myfile.eof()){ // loops through the file and reads it into the graph myfile >> col; myfile >> row; Array[row][col] = '*'; } } void readkeyboard(){ // loop this code until they enter -99 in your own way // call this function when you need it like this readkeyboard(); cout << "\nPlease enter row: "; cin >> row; cout << "\nPlease enter column: "; cin >> col; Array[row][col] = '*'; } void exit(){ ofstream myfile1, myfile2; myfile1.open("XYCanvas_StudentID.txt"); // put your number in here for (row = 21; row > 0; --row){ for (col = 0; col < 75; ++col) myfile1 << Array[row][col]; col = 0; myfile1 << "\n"; } myfile1.close(); myfile1.clear(); myfile2.open("Prog2_StudentID.txt"); // and your number in here myfile2 << "name and number"; // name and number myfile2.close(); myfile2.clear(); } void Scale(){ int Scaling; cout << "Scaling figure? "; cin >> Scaling; for (row = 0; row < 21; ++row) { for (col = 0; col < 75; ++col){ if (Array[row][col] == '*'){ Array[row][col] = '-'; Array[row*Scaling][col*Scaling] = 'X'; } } col = 0; } for (row = 0; row < 21; ++row) { for (col = 0; col < 75; ++col){ if (Array[row][col] == 'X') Array[row][col] = '*'; } col = 0; } } void Shift(){ int shift_up, shift_down; cout << "\nhow much up? "; cin >> shift_up; cout << "\nhow much up? "; cin >> shift_down; for (row = 0; row < 21; ++row) { for (col = 0; col < 75; ++col){ if (Array[row][col] == '*'){ Array[row][col] = '-'; Array[row+shift_up][col+shift_down] = 'X'; } } col = 0; } for (row = 0; row < 21; ++row) { for (col = 0; col < 75; ++col){ if (Array[row][col] == 'X') Array[row][col] = '*'; } col = 0; } } int main(){ // just a little test on the already complete functions Reset(); Display(); system("pause"); // menus supposed 2 go here??!? }; The menu looks like this void showMenu() { cout<< "\t\tC++ XY plotter Menu\n\n"; cout<< "\t1. Display XY plot\n"; cout<< "\t2. Read input from file\n"; cout<< "\t3. Read input from keyboard\n"; cout<< "\t4. Clear XY canvas\n"; cout<< "\t5. Scale/Shift figure\n"; cout<< "\t6. Exit program\n"; cout<< "\t7. Credits\n"; cout<< " Enter your choice: "; } any chance of any c++ enthusiasts having a crack at this or helping out? if the menu could function with the template this program will be running perfectly. any help will be greatley appreciated!:worried:
Sorry to be boring but sentence structure makes a lot of difference when you're explaining technical problems. If you can't be arsed with capital letters and full stops then at least put a line break between sentences. For example: - i am currently working on a program and i am trying to input a menu to run with a template i have - i am having trouble looping the menu with the template - the program is an X,Y plotter - i have a template up and running but i just cant get the menu to function with the template - some help will be greatley appreciated or if somone could teach me step's here it goes: I don't know what "input a menu to run with a template" means. Onto the code then. Code: // the initilize function call it like this when you need it Reset(); So have you been given a bunch of code (Reset(), Display() etc) and you just need to write the main function? Ah, is that what you mean by a template? Code: void readkeyboard(){ // loop this code until they enter -99 in your own way So what happens if someone does enter -99? There's no check for this in the function, so you'll get undefined behaviour when it tries to write to Array[-99][?] or Array[?][-99]. Code: // menus supposed 2 go here??!? No, probably not, because often "system("pause");" is the last thing a program does to prevent the DOS window from appearing briefly in Windows then disappearing before you get a chance to look at it. Can you write down what you think the main function should do, step by step? For example at the moment it calls Reset, then Display, then if you put the menu where the comment is, it would display the menu, then it would exit. Which I guess is probably not what you want; usually programs display the menu first, then get some input from the user, then act accordingly, repeating while the menu response isn't 6.