Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   comparing user input to an array element (http://www.go4expert.com/forums/comparing-user-input-array-element-t20551/)

Brett.h 29Dec2009 22:22

comparing user input to an array element
I have been working on this for a while but I can not seem to figure it out, the program compiles but if the user enters a string value that is equal to an element in the array, it doesn't fallow through with the appropriate code, it is equal, but it doesnt think it is.....
it sounds stupid but.......

    Gen Genesis;


string known_statements[known_reference] = {"HELLO"};

string Gen::get_userinput(){
    getline(cin, userinput);  //// I tested it by typing hello for the input /////
    return userinput;

void Gen::input_allcaps(string input){   
    for (int i = 0; i < input.length(); i++){
    cout << userinput;

string Gen::check_userinput(){
    for (int cntr = 0; cntr < known_reference; cntr++){
        if(userinput == known_statements[cntr]){
            cout << userinput << " = " << known_statements[cntr] << "n";
    return _response;

should i be using pointers, if so how?

any help would be appreciated


Gene Poole 30Dec2009 00:34

Re: comparing user input to an array element
From what you've shown here, I don't see any reason why it shouldn't work. Maybe you should show your real code?

All times are GMT +5.5. The time now is 23:04.