selection using arrow keys

Can someone help or tell me where the problem for this?
i can't find the error
i'm not send all the code, but it's error when i'm trying to use arrow selection

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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include <string.h>


#include <cstdlib>

typedef char string[100];
typedef struct {
	string data1,data2,data3;
}mobil;
typedef struct {
	string data1,data2;
}staff;
typedef struct {
	string data1,data2,data3,data4;
}peminjaman;
typedef struct {
	mobil m;
	staff s;
	peminjaman p;
}bentukan;
typedef struct tNode *address;
typedef struct tNode{
    bentukan data;
    address next;
}Node;
typedef struct
{
    address First;
}List;

address alokasi_mobil(mobil databaru);
void initialisasi (List &L);
int isEmpty (List L);
void insertLast_mobil(List &L, mobil databaru);
void deleteAt_mobil(List &L, mobil datahapus);
void printAll_mobil(List L);
address search_mobil(List l, mobil info);
void edit_mobil(List &L);
void deletefirst(List &L);
void edit_staff(List &L);
void printAll_mobil(List L);
void pinjam(List &L1,List &L2,List &L3);
void insertLast_staff(List &L, staff databaru);
address search_staff(List l, staff datacari);
address alokasi_staff(staff databaru);
void deleteAt_staff(List &L, staff info);
void insertLast_peminjaman(List &L, peminjaman databaru);
address alokasi_peminjaman(peminjaman databaru);
void deleteAt_peminjaman(List &L, peminjaman datahapus);
void kembali(List &L1,List &L2,List &L3);
address search_peminjaman(List l, peminjaman datacari);


void printAll_staff(List L)
{
 	if(isEmpty(L))
 	{
  		 printf("List Kosong...");
 	}
 	else
 	{
  		while(L.First!=NULL)
  		{
   			 printf("\nNama staff : ");printf("%s",L.First->data.s.data1);
   			 printf("\nNIP staff : ");printf("%s",L.First->data.s.data2);
   			L.First = L.First->next;
  		}
 	}
}

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition; 

void gotoXY(int x, int y) 
{ 
	CursorPosition.X = x; 
	CursorPosition.Y = y; 
	SetConsoleCursorPosition(console,CursorPosition); 
}


int main()
{
	
	int menu_item=0, run, x=7;
	bool running = true;
	
	int pil,a;
	List L1,L2,L3;
	mobil m;
	staff s;
	
	initialisasi(L1);
	initialisasi(L2);
	initialisasi(L3);
	
	system("cls");
	
	gotoXY(18,5);printf("Menu\n");
	gotoXY(18,7); printf("->");
	
	do
	{
		gotoXY(20,7);printf("1. Data mobil");
		gotoXY(20,8);printf("2. Data Staff");
		gotoXY(20,9);printf("3. Pinjam mobil");
		gotoXY(20,10);printf("4. Kembalikan mobil");
		gotoXY(20,11);printf("5. Laporan");
		gotoXY(20,12);printf("Quit Program");
		//printf("Pilihan : ");scanf("%d",&pil);
		system("pause>nul");
		if(GetAsyncKeyState(VK_DOWN) && x != 12) //down button pressed
			{
				gotoXY(18,x); printf("  ");
				x++;
				gotoXY(18,x); printf("->");
				menu_item++;
				continue;
			
			}
		
		if(GetAsyncKeyState(VK_UP) && x != 7) //up button pressed
			{
				gotoXY(18,x); printf("  ");
				x--;
				gotoXY(18,x); printf("->");
				menu_item--;
				continue;
			}
		
		if(GetAsyncKeyState(VK_RETURN)){ // Enter key pressed
		
		switch(menu_item)
		{
			case 0 : 
				do
				{
					system("cls");
					printf("Menu mobil");
					printf("\n1. Masukkan");
					printf("\n2. Edit");
					printf("\n3. Hapus");
					printf("\n0. Kembali");
					printf("\nPilihan : ");scanf("%d",&a);
					switch(a)
					{
						case 1 :
							printf("Plat nomor mobil : ");fflush(stdin);gets(m.data1);
							printf("Merk mobil : ");fflush(stdin);gets(m.data2);
							strcpy(m.data3,"Tersedia");
							insertLast_mobil(L1,m);
							break;
						case 2 : 
							edit_mobil(L1);
							break;
						case 3 : 
							printf("Plat nomor mobil : ");fflush(stdin);gets(m.data1);
							printf("Merk mobil : ");fflush(stdin);gets(m.data2);
							deleteAt_mobil(L1,m);
							getch();
							break;
					}
				}while(a!=0);
				break;
			case 1 : 
				do
				{
					system("cls");
					printf("Menu staff");
					printf("\n1. Masukkan");
					printf("\n2. Edit");
					printf("\n3. Hapus");
					printf("\n0. Kembali");
					printf("\nPilihan : ");scanf("%d",&a);
					switch(a)
					{
						case 1 :
							printf("Nama staff : ");fflush(stdin);gets(s.data1);
							printf("NIP staff : ");fflush(stdin);gets(s.data2);
							insertLast_staff(L2,s);
							break;
						case 2 :
							edit_staff(L2);
							break;
						case 3 : 
							printf("Nama staff : ");fflush(stdin);gets(s.data1);
							printf("NIP staff : ");fflush(stdin);gets(s.data2);
							deleteAt_staff(L2,s);
							break;
					}
				}while(a!=0);
				break;
			case 2 : 
				pinjam(L1,L2,L3);
				break; 
			case 3 :
				kembali(L1,L2,L3);
				getch();
				break;
			case 4 :
				do
				{
					system("cls");
					printf("Menu laporan");
					printf("\n1. Laporan data mobil");
					printf("\n2. Laporan data staff");
					printf("\n3. Laporan peminjaman sebuah mobil");
					printf("\n4. Laporan peminjaman seorang staff");
					printf("\n5. Laporan peminjaman terbanyak dari staff");
					printf("\n0. Kembali");
					printf("\nPilihan : ");scanf("%d",&a);
					switch(a)
					{
						case 1 :
							printAll_mobil(L1);
							getch();
							break;
						case 2 : 
							printAll_staff(L2);
							getch();
							break;
						case 3 : 
							printf("Plat nomor mobil : ");fflush(stdin);gets(m.data1);
							printf("Merk mobil : ");fflush(stdin);gets(m.data2);
					
					}	
				}while(a!=0);
				break;
			case 5: 
				{
					gotoXY(20,20);
					printf("The program has now terminated!!");
					running = false;
				}
			
		}
		while(running!=false);
		gotoXY(20,21);
		return 0;
	}
	
}
closed account (2UD8vCM9)
It appears it was a problem with the opening and curly braces. Keep in mind I wasn't able to test the code since I can't compile it due to missing the headers/cpps for functions called in the program.

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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include <string.h>
#include <cstdlib>


typedef char string[100];
typedef struct {
	string data1, data2, data3;
}mobil;
typedef struct {
	string data1, data2;
}staff;
typedef struct {
	string data1, data2, data3, data4;
}peminjaman;
typedef struct {
	mobil m;
	staff s;
	peminjaman p;
}bentukan;
typedef struct tNode *address;
typedef struct tNode{
	bentukan data;
	address next;
}Node;
typedef struct
{
	address First;
}List;

address alokasi_mobil(mobil databaru);
void initialisasi(List &L);
int isEmpty(List L);
void insertLast_mobil(List &L, mobil databaru);
void deleteAt_mobil(List &L, mobil datahapus);
void printAll_mobil(List L);
address search_mobil(List l, mobil info);
void edit_mobil(List &L);
void deletefirst(List &L);
void edit_staff(List &L);
void printAll_mobil(List L);
void pinjam(List &L1, List &L2, List &L3);
void insertLast_staff(List &L, staff databaru);
address search_staff(List l, staff datacari);
address alokasi_staff(staff databaru);
void deleteAt_staff(List &L, staff info);
void insertLast_peminjaman(List &L, peminjaman databaru);
address alokasi_peminjaman(peminjaman databaru);
void deleteAt_peminjaman(List &L, peminjaman datahapus);
void kembali(List &L1, List &L2, List &L3);
address search_peminjaman(List l, peminjaman datacari);


void printAll_staff(List L)
{
	if (isEmpty(L))
	{
		printf("List Kosong...");
	}
	else
	{
		while (L.First != NULL)
		{
			printf("\nNama staff : "); printf("%s", L.First->data.s.data1);
			printf("\nNIP staff : "); printf("%s", L.First->data.s.data2);
			L.First = L.First->next;
		}
	}
}

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;

void gotoXY(int x, int y)
{
	CursorPosition.X = x;
	CursorPosition.Y = y;
	SetConsoleCursorPosition(console, CursorPosition);
}


int main()
{

	int menu_item = 0, run, x = 7;
	bool running = true;

	int pil, a;
	List L1, L2, L3;
	mobil m;
	staff s;

	initialisasi(L1);
	initialisasi(L2);
	initialisasi(L3);

	system("cls");

	gotoXY(18, 5); printf("Menu\n");
	gotoXY(18, 7); printf("->");

	do
	{
		gotoXY(20, 7); printf("1. Data mobil");
		gotoXY(20, 8); printf("2. Data Staff");
		gotoXY(20, 9); printf("3. Pinjam mobil");
		gotoXY(20, 10); printf("4. Kembalikan mobil");
		gotoXY(20, 11); printf("5. Laporan");
		gotoXY(20, 12); printf("Quit Program");
		//printf("Pilihan : ");scanf("%d",&pil);
		system("pause>nul");
		if (GetAsyncKeyState(VK_DOWN) && x != 12) //down button pressed
		{
			gotoXY(18, x); printf("  ");
			x++;
			gotoXY(18, x); printf("->");
			menu_item++;
			continue;

		}

		if (GetAsyncKeyState(VK_UP) && x != 7) //up button pressed
		{
			gotoXY(18, x); printf("  ");
			x--;
			gotoXY(18, x); printf("->");
			menu_item--;
			continue;
		}

		if (GetAsyncKeyState(VK_RETURN))
		{ // Enter key pressed
			switch (menu_item)
			{
			case 0:
				do
				{
					system("cls");
					printf("Menu mobil");
					printf("\n1. Masukkan");
					printf("\n2. Edit");
					printf("\n3. Hapus");
					printf("\n0. Kembali");
					printf("\nPilihan : "); scanf("%d", &a);
					switch (a)
					{
					case 1:
						printf("Plat nomor mobil : "); fflush(stdin); gets(m.data1);
						printf("Merk mobil : "); fflush(stdin); gets(m.data2);
						strcpy(m.data3, "Tersedia");
						insertLast_mobil(L1, m);
						break;
					case 2:
						edit_mobil(L1);
						break;
					case 3:
						printf("Plat nomor mobil : "); fflush(stdin); gets(m.data1);
						printf("Merk mobil : "); fflush(stdin); gets(m.data2);
						deleteAt_mobil(L1, m);
						getch();
						break;
					}
				} while (a != 0);
				break;
			case 1:
				do
				{
					system("cls");
					printf("Menu staff");
					printf("\n1. Masukkan");
					printf("\n2. Edit");
					printf("\n3. Hapus");
					printf("\n0. Kembali");
					printf("\nPilihan : "); scanf("%d", &a);
					switch (a)
					{
					case 1:
						printf("Nama staff : "); fflush(stdin); gets(s.data1);
						printf("NIP staff : "); fflush(stdin); gets(s.data2);
						insertLast_staff(L2, s);
						break;
					case 2:
						edit_staff(L2);
						break;
					case 3:
						printf("Nama staff : "); fflush(stdin); gets(s.data1);
						printf("NIP staff : "); fflush(stdin); gets(s.data2);
						deleteAt_staff(L2, s);
						break;
					}
				} while (a != 0);
				break;
			case 2:
				pinjam(L1, L2, L3);
				break;
			case 3:
				kembali(L1, L2, L3);
				getch();
				break;
			case 4:
				do
				{
					system("cls");
					printf("Menu laporan");
					printf("\n1. Laporan data mobil");
					printf("\n2. Laporan data staff");
					printf("\n3. Laporan peminjaman sebuah mobil");
					printf("\n4. Laporan peminjaman seorang staff");
					printf("\n5. Laporan peminjaman terbanyak dari staff");
					printf("\n0. Kembali");
					printf("\nPilihan : "); scanf("%d", &a);
					switch (a)
					{
					case 1:
						printAll_mobil(L1);
						getch();
						break;
					case 2:
						printAll_staff(L2);
						getch();
						break;
					case 3:
						printf("Plat nomor mobil : "); fflush(stdin); gets(m.data1);
						printf("Merk mobil : "); fflush(stdin); gets(m.data2);

					}
				} while (a != 0);
				break;
			case 5:
			{
				gotoXY(20, 20);
				printf("The program has now terminated!!");
				running = false;
			}
			}//end of switch
		} //end of if enter key pressed - if (GetAsyncKeyState(VK_RETURN))
	} while (running != false);
	gotoXY(20, 21);
	return 0;
}
thanks
Topic archived. No new replies allowed.