收到我似乎无法解决的两个错误

时间:2017-04-30 06:31:55

标签: c++

这段代码的想法是将一个单词存储在一个字符向量中并交换字母:

void scrambleWords(vector<string>& words, vector<char>& scramWord)
{
  string scram;
  char randChar;

  //get random value
  srand(time(0));
  int randNumWords = (rand() % 5 - 0);

  //choose word from vector based on random value
  scram = words.at(randNumWords);

  //put each letter into char vector
  for (unsigned int j = 0; j < scram.size(); j++)
  {
    scram.at(j) = scramWord.push_back; //non-standard syntax; use '&' to 
    // Screate pointer for member AND '=' unable to resolve function overload
  }

  //get another random value, find random char within char vector, place at 
  end of vector
  for (unsigned int k = 0; k < scramWord.size(); k++)
  {
    int randNumScram = (rand() % scramWord.size() - 0);
    randChar = scramWord.at(randNumScram);
    scramWord.push_back(randChar);
  }
}

错误消息在第一个for循环中。

我试图用我教科书和网上的信息来解决这个问题。

似乎还无法弄明白。对于我想要完成的事情,我是否过于复杂?感谢。

0 个答案:

没有答案