comparing user input to an array element

Brett.h's Avatar
Light Poster
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's Avatar, Join Date: Nov 2009
From what you've shown here, I don't see any reason why it shouldn't work. Maybe you should show your real code?