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?

Recommended Answers

All 3 Replies

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

Chris

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!

Mark as solved please

Chris

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.