I have this code which runs in dev c++ but i want it to run in turbo c++.

closed account (y6q2y60M)
I have this code which runs in dev c++ but i want it to run in turbo c++.
can anyone please convert it so that it can run in turbo c++.
please!!!

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
  #include <iostream>
#include <string>
#include <windows.h>

using namespace std;

int main()
{
	string Menu[3] = {"Start Game", "Options", "Exit"};
	int pointer = 0;
	
	while(true)
	{
		system("cls");
		
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
		cout << "Main Menu\n\n";
		
		for (int i = 0; i < 3; ++i)
		{
			if (i == pointer)
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 11);
				cout << Menu[i] << endl;
			}
			else
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
				cout << Menu[i] << endl;
			}
		}
		
		while(true)
		{
			if (GetAsyncKeyState(VK_UP) != 0)
			{
				pointer -= 1;
				if (pointer == -1)
				{
					pointer = 2;
				}
				break;
			}
			else if (GetAsyncKeyState(VK_DOWN) != 0)
			{
				pointer += 1;
				if (pointer == 3)
				{
					pointer = 0;
				}
				break;
			}
			else if (GetAsyncKeyState(VK_RETURN) != 0)
			{
				switch (pointer)
				{
					case 0:
					{
						cout << "\n\n\nStarting new game...";
						Sleep(1000);
					} break;
					case 1:
					{
						cout << "\n\n\nThis is the options...";
						Sleep(1000);
					} break;
					case 2:
					{
						return 0;
					} break;
				}
				break;
			}
		}
		
		Sleep(150);
	}
	
	return 0;
}
did you try to compile ? It should works , but try to avoid magic numbers .
closed account (y6q2y60M)
@Ericool
i did but turbo doesn't support many of the functions used in this. :(
that is really strange , but it seems that GetAsyncKeyState could be the issue. Could you try with a code similar to 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
25
26
27
28
29
#include <iostream>
#include <windows.h>
#include <conio.h>

    using namespace std;

int main()
{
    bool repeat = true;
    while (repeat)
    {
        cout << '*';
        Sleep(100);

        if (kbhit())
        {
            char ch = getch();
            switch (ch)
            {
                case 27:               // press ESC to exit
                    repeat = false;
                    break;
                case 32:               // press SPACE to clear screen
                    clrscr();
                    break;
            }
        }
    }
    return 0;
closed account (y6q2y60M)
@Ericool

i need to run this program in turbo c++ which doesn't support windows.h and many new features.
that would be the issue then . Look at this thread , maybe you could find your solution.
Good luck :( .

http://stackoverflow.com/questions/21257544/c-wait-for-user-input
closed account (y6q2y60M)
@Ericool

really appreciate you help.
but that part was understood by me . The main problem was the text getting highlighted when the arrow key is pressed .

i couldn't find a solution to that.
Topic archived. No new replies allowed.