Cannot find logical operator

Here is 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
#include <iostream>
#include <string>
using namespace std;
string repeat;
string repeatnum;
string prompt = "|-[]->";
int main()
{
    string entry;
    bool Running = true;
    while(Running == true)
    {
    cout << "\n";
    cout << prompt;
    cin >> entry;
    if(entry == "Exit") return 0;
    if(entry == "Help") cout << "HELP:\nThsi is a simple program, try an input";
    if(entry == "ChangePrompt")
    {
        cout << "What do you want to change the prompt to?: ";
        cin >> prompt;
    }
    if(entry == "Repeat" || "repeat")
    {
        cout << "What string do you want to repeat?: ";
        cin >> repeat;
        cout << "How many times do you want to repeat" << repeat << "(1-9)?: ";
        cin >> repeatnum;
        if(repeatnum > 0){}
    }
    }
    char f;
    cin >> f;
    return 0;
}

Here are the error messages:
1
2
3
4
||=== test, Debug ===|
C:\Users\Packard Bell\Desktop\test\main.cpp||In function 'int main()':|
C:\Users\Packard Bell\Desktop\test\main.cpp|29|error: no match for 'operator>' in 'repeatnum > 0'|
||=== Build finished: 1 errors, 0 warnings ===|
You're trying to use the > operator on a string.
Hi,

This bit isn't right either:

if(entry == "Repeat" || "repeat")

should be this:

if(entry == "Repeat" || entry == "repeat")

Instead of a series of if's you need, an if, some else if's, then an else.

This bit needs to be a for loop:

if(repeatnum > 0){}

HTH
You know

1
2
3
4
5
6
7
8
9
//you can declare repeatnum as an int instead
int repeatnum;

cin >> repeatnum;

if(repeatnum > 0)
{
     //Whatever
}


I dont see the need to declare repeatnum as string.
Thanks guys,
I feel stupid now. :0
Topic archived. No new replies allowed.