0

im having a bit of trouble with this for loop. can somone show me what im doing wrong?

runcount = runcount + 1;
      cout << "Type a number: \n";
     cin >> s; 
            guesssheet[runcount] = s;
            for(int y = 0; y < runcount; ++y)
            {
                  if(guesssheet[y] = s)
                  {
                                   system("cls");
                       cout << "Sorry, you have already guessed that number. try again.\n\n";
                       GetResults();
                       }
                  }

and this is the error i get:

165 C:\Dev-Cpp\Examples\Jackpot\main.cpp could not convert `((+(((unsigned int)y) * 4u)) + ((std::string*)(&guesssheet)))->std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)(&s))))' to `bool'

so am i doing somthing wrong?

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Freaky_Chris
0

guesssheet[y] = s in your if statement it should be ==
You are trying to set it equal to rather than comparing

Chris

0

guesssheet[y] = s in your if statement it should be ==
You are trying to set it equal to rather than comparing

Chris

oh. oops. thank you so much!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.