これは、do while ループを使用した C++ を使用した私の完全なプログラムです。最初は正しく動作しますが、ループすると正しく動作しません。
このプログラムは name を配列に格納し、出力します。配列のサイズは 50 なので、配列に 50 個の名前を格納したいと考えています。
どんな助けでも大歓迎です。ありがとう。
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
void start(int c);
string NameArray [50];
char response;
int main() {
int count=1;
do {
count = count - 1;
start(count);
cout << "do you want to add another name? ";
cin>> response;
count = count + 2;
cout<< endl;
} while (tolower(response)=='y');
cout<< "program Ends" <<endl;
system ("pause");
return 0;
}
void start(int count) {
cout<< "Enter your First and Last name: ";
getline(cin, NameArray[count]);
cout<< NameArray[count] <<endl;
cout<< endl;
}