配列に文字の行を入力する際に問題があります。ここに主要な問題があります。私はサイズ50の配列を宣言したと私は私の名前を入力したいと言うことができますが、私はループを使用してそれを格納していないループを入力したときに私は50文字まで入力したまでループを実行し続ける:/ この問題を回避できますか? は例のおかげで説明:)あなたはこの間違った方法をやっている文字の行を入力する
void option1()//here user inputs the data
{
string name[20];
string date[20];
string from[20];
string to[20];
string id_no[20];
system("CLS");
cout << "\n\n\t\tEnter your seat no.: ";
cin >> seat;
while(seat>32 || seat<0)
{
cout << "\n\t\tThere are no seats greater than 32 please type in again: ";
cin >> seat;
}
cout << "\t\tEnter your name: ";
cin >> name[seat];
cout << "\t\tEnter Your date: ";
cin >> date[seat];
cout << "\t\tEnter your ID No. :";
cin >> id_no[seat];
cout << "\t\tWhere do you want to travel:\n ";
cout << "\t\t\tFrom: ";
cin >> from[seat];
cout << "\t\t\tTo: ";
cin >> to[seat];
system("CLS");
cout << "\n\n\t\tTHANK YOU! YOUR SEAT HAS BEEN BOOKED\n";
getchar();
system("CLS");
}
void option2()//From here how can i bring the data to this funciton?
{
string name[20];
string date[20];
string from[20];
string to[20];
string id_no[20];
cout << "\t\t\tEnter your seat number: ";
cin >> seat;
cout << "\t\tYour Name: " << name[seat] << endl;
cout << "\t\tYour Date of travelling: " << date[seat] << endl;
cout << "\t\tYour ID no. : " << id_no[seat] << endl;
cout << "\t\tTravelling From: " << from[seat] << endl;
cout << "\t\tTravelling To: " << to[seat] << endl;
}
あなたが試行したことを表示します。 – Unimportant
いいえ、あなたの質問を編集し、あなたのコードを質問の一部として表示してください。 –
@SamVarshavchik申し訳ありませんが、私はこれで初めてです: '3 –