だからここに私のコードがあります、
#include <iostream>
#include <string>
using namespace std;
int main()
{
const int NUM_NAMES = 20;
string names [NUM_NAMES] = {"Collins, Bill", "Smith, Bart" , "Allen, Jim", "Griffin, Jim", "Stamey, Marty", "Rose, Geri","Taylor, Terri",
"Johnson, Jill", "Allison, Jeff", "Looney, Joe" , "Wolfe, Bill", "Rutherford, Greg", "Javens, Renee","Harrison, Rose","Setzer, Cathy",
"Pike, Gordon","Holland, Beth"};
string smallest;
int minindex;
void displayNames (string[NUM_NAMES], int);
cout<<"Here are the unalphabetized names";
****displayNames(names[NUM_NAMES], NUM_NAMES);****
for(int i=0; i < (NUM_NAMES -1); i++)
{
minindex=i;
smallest=names[i];
for(int j = (i+1); j<NUM_NAMES; j++)
{
if(names[j]<smallest)
{
smallest = names[j];
minindex = j;
}
}
names[minindex] =names[i];
names[i] = smallest;
system("pause");
return 0;
}
}
void displayNames(string names[], int NUM_NAMES)
{
for (int i =0; i<NUM_NAMES; i ++)
{
cout<<names[i]<<endl;
}
}
4 つのアスタリスクで囲まれた行は、ビルドしようとしたときにエラー コードが参照する行です。私の実際のコードにはアスタリスクはありません。エラーの修正方法がわかりません
Intellisense: no suitable conversion function from "std::string" to "std::string *" exists
string to int
検索のページとページを調べましたが、すべての質問/回答は、またはstring to char
などからの変換関数を参照しているようstring to string
です。
ちなみに、これらをアルファベット順に並べる必要もありますが、現在持っているものは機能しますか? 私の教授は、コンピューターは文字列の char 値を評価するべきだと言っていた。