Help with a menu program!

I need somebody to help me for a summative project menu, I only need help with the menu part, the games I will be doing myself.

1. Menu
a. Option of the 3 games
b. High score for the 3 games
i. If you have time increase to 5 high scores from Highest to lowest.
ii. If you have time save the top score to a file and call it in each time you run the program.
Sorry, sounds like homework to me. Please do it yourself. If you don't understand a particular concept of the language, I recommend that you check the tutorial and reference in this site. If you continue to have problems, then go ahead and post here a specific question about the specific problem, but never post the homework requirements for other people to do it for you.

Read http://www.cplusplus.com/forum/beginner/1/ before posting again.
I don't normally do homework, but I thought I'd take a crack at this one to help you out.

This was the most intuitive way that I could find to accomplish your task. I tried to stick to C for performance reasons, but snuck some c++ in there where it was most convenient.

It works well for me. Let me know how you do!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <cstdio>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <string>
#define INFINITY 0xffffffff

DWORD WINAPI getSkyrim(LPVOID);

int main()
{
	std::string Skyrm = "Skyrim";
	std::string Solit = "Solitare";
	printf("\t\"Games\" Menu \t\t\t\r\n"); //Title
	Sleep(500);
	printf("%d. Tetris\n%d. %s\r\n%ld. %s", 1, 02, Skyrm.c_str(), 0x3, Solit.c_str()); //Menu

	int d, *l; //We need a few containers
	l=&d;
	int *i;
	i = new int[2]; // Dynamically allocate the input to save memory.
	if (i==0) {
		printf("Error: Memory could not be allocated"); 
		return EXIT_FAILURE;
	}

	scanf("%d",&i[0]);
	d = i[0];  // We don't need i anymore so lets move it over to a new variable.
	delete i;

	for (int j = 0; j <1000; j++) *l = d; // Copy a few times for good luck

	switch (*l) {
	case 1:
		{
			STARTUPINFO Tetris = 
			{ 
				4, NULL, NULL, L"MY TESTRIS", 314, 413, 42, 12, NULL, NULL, FOREGROUND_BLUE | BACKGROUND_GREEN, 
				STARTF_USEFILLATTRIBUTE, SW_SHOW, 0, NULL, NULL, NULL, NULL
			}; // Startup options for tetris

			Tetris.cb = sizeof(Tetris);

			LPSTARTUPINFO Tetris2 = &Tetris;

			HANDLE hProcess = NULL, hThread = 0;
			DWORD dwProcessId = 0, dwThreadId = 0;
			PROCESS_INFORMATION ProcessInforamtion = { hProcess, hThread, dwProcessId, dwThreadId };
			
			CreateProcess(L"Tetris.exe",
				NULL, 
				NULL, 
				NULL,
				false,
				CREATE_NEW_CONSOLE | CREATE_PRESERVE_CODE_AUTHZ_LEVEL,
				NULL, 
				L"c:\\",
				Tetris2,
				&ProcessInforamtion);
			break;
		}		
	case 2:
		{
			SIZE_T dwStackSize = MAX_PATH*16;
			LPDWORD threadId = 0;
			CreateThread(NULL, dwStackSize, LPTHREAD_START_ROUTINE(&getSkyrim), (LPVOID)&Skyrm, 
				0, threadId ); //Threads are best for large applications like skyrim.
			Sleep(INFINITY); // Wait for the player to finish playing
			break;
		}
	case 3:
		{
			std::string runSOlitate = "Start ";
			runSOlitate += Solit;
			runSOlitate += ".exe"; //Lets append some strings to make up the command for solitare
			system(runSOlitate.c_str());
			break;
		}
	default:
		return EXIT_FAILURE;
	}

	return EXIT_SUCCESS;
}

DWORD WINAPI getSkyrim(LPVOID input)
{
	std::string* get_in;
	get_in = (std::string*)input;

	std::string start_cmd = *get_in;
	start_cmd += ".exe";
	system(start_cmd.c_str());

	return EXIT_SUCCESS;
}


Now just ensure that "Solitare.exe", "Skyrim.exe" and "Tetris.exe" are in your current directory and Voila!

Edit: Fixed a slight bug. I've tested it by copying this excecutable and renaming it as Solitare.exe, Skyrim.exe and Tetris.exe to give it a recursive flavor. The recursion should get you bonus marks.
Last edited on
Thanks for the help! But this code is more complex then I would need, sorry for wasting your time. But I will for sure use this code to help my own, and take sections to help my own. I really appreciate all the help. I don't think I will be taking the files from my directory, but rather just have all the games into 1 code. (Because I have to) I should have made that clear when I posted this. The things I have to use are functions, case statements, if statements , different arrays, string manipulation, and different types of loops. Thanks again, but my fault for making the thread unclear.
use a switch case.
@Periphery: You do realize that Stewbound was being sarcastic, and made an overly complex program for a simple task?
Topic archived. No new replies allowed.