Shorten console menu

I have a console window that functions, but the menu is less than pleasing to the eye, and takes up a lot of screen space. Does anyone know the best way to condense these to take up less space? I've thought of having sub menus and splitting them up into rows and columns, but am not sure which is better or even if there's a better way. Here is the code for displaying the options.

1
2
3
4
5
cout << "\n Choose an option: \n" << " 1 = Radians/Degrees converter \n 2 = Kinetic Energy \n 3 = Momentum \n 4 = Impulse \n 5 = Force";
cout << "\n 6 = Work \n 7 = Power \n 8 = Grav. Force \n 9 = Velocity of a wave \n 10 = Spring force \n 11 = Frequency";
cout << "\n 12 = Wavelength \n 13 = Period \n 14 = Pythag. Thm. \n 15 = Inverse Pythag. Thm \n 16 = Quadratic Eqn Slvr \n 17 Clear Console text\n";

// I used 3 couts instead of one massive to keep the code easier to read. This, of course, does nothing for the console window. 


Any help/suggestions are appreciated.
Last edited on
Try this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <Windows.h>
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
	// Create a .txt file with the menu options
	ofstream oFile ("Menu Text.txt");
	oFile << "\n Choose an option: \n" << " 1 = Radians/Degrees converter \n 2 = Kinetic Energy \n 3 = Momentum \n 4 = Impulse \n 5 = Force";
	oFile << "\n 6 = Work \n 7 = Power \n 8 = Grav. Force \n 9 = Velocity of a wave \n 10 = Spring force \n 11 = Frequency";
	oFile << "\n 12 = Wavelength \n 13 = Period \n 14 = Pythag. Thm. \n 15 = Inverse Pythag. Thm \n 16 = Quadratic Eqn Slvr \n 17 Clear Console text\n";
	oFile.close ();
	// Open the .txt file
	ShellExecute (NULL, "open", "Menu Text.txt", NULL, NULL, SW_SHOW);
	// Ask for input
	cout << "Input: ";
	int iInput (0);
	cin >> iInput;
	switch (iInput)
	{
		// Hanlde the menu input here
	}
	return 0; // exit program
}


Or make a Win32 API application, which will require a lot more learning but will make the program have a GUI.
Last edited on
Ok, I'll try it with the ShellExecute command. C::B has code for creating a window, but I could never figure out how to add anything to it (buttons, text, etc...). Thanks.
Topic archived. No new replies allowed.