I am writing a program that prompts the user for the name and age of a group of people. The group's size is unknown initially, so the program must keep asking the user if they want to enter more data. It has been a while since I have worked with C++ so I am trying to figure out how to take the user inputs of name and ages into an array until the user wants to stop imputing information.
I know this is incorrect but maybe you guys could help steer me in the right direction.
Code:char name[15]; int age[3]; char answer; int i; while(answer=='y'||'Y') { cout << "Enter name: "; cin >> name[i]; cout << "Age: "; cin >> age[i]; cout << "Would you like to add another person? (Y/N)"; cin >> answer; }



LinkBack URL
About LinkBacks



