Hey guys, I've run into a small problem on this program I was creating. It's supposed to be a simple database using arrays to store names in strings and ages in a separate array. Unfortunately, when I try to have the program echo back all the inputted data, it fails and just inputs the first name and age entered. Take a look:
Code:
//This is a program that allows you to create a simple database and output it all to a text file
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main() {
string name[10];
int age[10];
int input;
int i; //counting
int a;//counting
a = 0;
i = 0;
mainmenu:
cout << "Database Manager" << endl;
cout << "1: New Database" << endl;
cout << "2: Load Database" << endl;
cout << "3: View Database" << endl;
cout << "4: Edit Database" << endl;
cin >> input;
switch (input) {
case 1:
while (i < 10) {
cout << endl;
cout << "Enter the info for each person. Limit of 10 people."<< endl << "Type 'back' to return to the main menu"<< endl; //back function not implemented yet
cout << "Input Name: " << endl;
cin >> name[i];
cout << "Input Age: "<< endl;
cin >> age[i];
i++;
}
break;
case 3:
for (a=0; a<10; a++) {//tried different kinds of loops, can't get it to print the arrays correctly
cout << name[a] << endl << age[a] << endl << endl; //should print out every name and age
}
break;
}
goto mainmenu;
}
Thanks in advance for any help