Error ')' Before string constant

What should i do?
Here's my code
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
 #include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    while (1)
    {
        char choice[2];

        cout << ": :Menu: :\n\n"
             << "1. Option 1\n"
             << "2. Option 2\n"
             << "3. Exit Program\n\n"
             << "Choice: ";
        cin >> choice;

          if (choice[0] "" '1')
        {
           system  ("CLS"); //all system commands are only used by windows, sorry mac
           cout << "Option 1\n\n";
           system ("PAUSE");
           system ("CLS");
        }

         else if (choice[0] "" '2' )
        {
            system  ("CLS");
           cout << "Option 2\n\n";
           system ("PAUSE");
           system ("CLS");
        }

         else if (choice[0] "" '3' )
        {
            return 0;
        }


        else if (choice[0] >'3' || choice[0] <'1') //user input vaidation
        {
            system ("CLS");
            cout << "Invalid Input\n\n";
            system ("PAUSE");
            system ("CLS");
        }

        else
        {
            system ("CLS");
            cout << "Invalid Input\n\n";
            system ("PAUSE");
            system ("CLS");
        }

    }
if (choice[0] "" '1') // what is this "" ?

Don't you mean - if (choice[0] == '1') // if it's equal to '1'. "" doesnt do anything.
Thanks TarikNeaj
I forgot. The code is now ok

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
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    while (1)
    {
        char choice[2];

        cout << ": :Menu: :\n\n"
             << "1. Option 1\n"
             << "2. Option 2\n"
             << "3. Exit Program\n\n"
             << "Choice: ";
        cin >> choice;

          if (choice[0] == '1')
        {
           system  ("CLS"); 
           cout << "Option 1\n\n";
           system ("PAUSE");
           system ("CLS");
        }

         else if (choice[0] == '2' )
        {
            system  ("CLS");
           cout << "Option 2\n\n";
           system ("PAUSE");
           system ("CLS");
        }

         else if (choice[0] == '3' )
        {
            return 0;
        }


        else if (choice[0] >'3' || choice[0] <'1') //user input vaidation
        {
            system ("CLS");
            cout << "Invalid Input\n\n";
            system ("PAUSE");
            system ("CLS");
        }

        else
        {
            system ("CLS");
            cout << "Invalid Input\n\n";
            system ("PAUSE");
            system ("CLS");
        }

    }
}

Last edited on
Are you possibly looking for something like 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
30
31
32
33
34
#include <iostream>

int main(){
	int choice;
	std::cout << ": :Menu: :\n\n"
		<< "1. Option 1\n"
		<< "2. Option 2\n"
		<< "3. Exit Program\n\n"
		<< "Choice: ";
	std::cin >> choice;

	switch (choice){
	case 1:
		system("CLS");							// please..
		std::cout << "Option 1\n\n";
		system("PAUSE");						// dont
		system("CLS");							// do this
		break;								
	case 2:
		system("CLS");							// please
		std::cout << "Option 2\n\n";
		system("PAUSE");						// just
		system("CLS");							// stop 
		break;
	case 3:
		return 0;
		break;
	default:									// if not 1 2 or 3
		std::cout << "That ain't no choice I ever heard of!" << std::endl;
		break;
	}

	return 0;
}
Last edited on
Topic archived. No new replies allowed.