Double Wrong entry output instead of one help

Sometimes code outputs twice wrong entry. What is wrong?

edit: fixed lenght to length

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
  #include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <map>


using namespace std;

int main () {
    map<string,int> m = {{"zero", 0}, {"one", 1}, {"two", 2}, {"three", 3}, {"four", 4},
                        {"five", 5}, {"six", 6}, {"seven", 7}, {"eight", 8}, {"nine", 9}};

    string input, TRANSFORMEDinput;
    while (true) {
        cout << "Enter number from 0-9 with word:" << endl;
        getline(cin, input);
        TRANSFORMEDinput=input;
        if(input.length()>5)
        {
        cout<<"Wrong entry!"
        }else
        transform( TRANSFORMEDinput.begin(),
        TRANSFORMEDinput.end(),
        TRANSFORMEDinput(),
        ::tolower);
        if (m.find(TRANSFORMEDinput) == m.end()) {
            cout << "Wrong entry!" << endl;
        } else break;
    }

    for (int i = 1; i <= m[TRANSFORMEDinput]; i++) {
        for (int j = 1; j <= i; j++) {
            cout << input;
            if (j != i) cout << ", ";
        }
        cout << endl;
    }

    cin.get();
    return EXIT_SUCCESS;
}
Last edited on
It means you spelled length wrong.
Ha-Ha... although now sometimes outputs twice wrong entry...
Topic archived. No new replies allowed.