ここで初めて質問するので、間違っていたらごめんなさい。だから私はランキングの壁を作ろうとしている間、私はゲームのプレーヤーの名前とスコアを持つベクトル型を持っているこの関数を持っています。プログラムのこの特定の部分では、文字列を int に変換する必要があります。文字列部分は実際には文字列ベクトルの数値であり、他の数値と比較できるように int にする必要があるため、次のようになります。
void exibir_ranking(vector<string> &ranking) //dentro do laco, procura qual o maior score, imprime ele na tela juntamente com o nome correspondente no outro vetor depois apaga o valor e o nome dos vectors
{
int k;
vector <string> nomes;
vector <int> pontuacoes;
for(int i=0;i<ranking.max_size();i++) {
if(i==0 || i%2 ==0) nomes.push_back(ranking[i]);
else if(i==1 || i%2!=0) {
int aux = atoi(ranking[i].c_str);
pontuacoes.push_back(aux);
}
}
cout << "\n\n\t\tRANKING:\n\n";
while(pontuacoes.size()!=0){
int maior =0;
for (k=0; k< pontuacoes.max_size(); k++){
if(pontuacoes[k] > maior) maior = pontuacoes[k];
}
cout << k << "- " << "Nome: " << nomes[k] << "\tScore: "<<pontuacoes[k] << endl;
nomes.erase (nomes.begin()+k);
pontuacoes.erase (pontuacoes.begin()+k);
}
cout<<"\n----------------------------";
}
そのため、ビジュアルスタジオは、問題がまさにここにあると言っています:
else if(i==1 || i%2!=0) {
int aux = atoi(ranking[i].c_str);
pontuacoes.push_back(aux);
}
言うように:
エラー 4 エラー C3867: 'std::basic_string<_Elem,_Traits,_Alloc>::c_str': 関数呼び出しに引数リストがありません。'&std::basic_string<_Elem,_Traits,_Alloc>::c_str' を使用して、メンバ c:\users\user\google drive\mackenzie\projeto programacao\projeto\projeto\jogo.cpp へのポインタを作成します 247
誰でもこれで私を助けることができますか?