まず、これは「宿題」の質問であるため、ベクターライブラリと文字列ライブラリは立ち入り禁止です。私はC++の基本に到達しようとしています。
このコードでの私の意図は、文字列配列の配列を作成して使用することです。言い換えれば、単語のリスト。
このコードを実行すると、ナンセンスがたくさん出てきます。
C ++で単語のリストを作成するためのより良い方法があれば、私はそれについて聞いてみたいです。
const int cart_length = 50;
const int word_length = 50;
int main()
{
char cart_of_names[cart_length][word_length];
float cart_of_costs[cart_length];
char name[word_length];
cout << "enter the name of the first item: ";
cin >> name;
for(int i=0; i<word_length; i++)
{
cart_of_names[0][i] = name[i];
}
cout << endl;
cout << "that is: ";
for(int x=0; x<word_length; x++)
{
cout << cart_of_names[0][x];
}
cout << endl;
return 0;
}