I'm trying to make a very basic database but it it's either not writing to the array properly or it's not printing the data properly, and i have no idea why, i've been trying to figure it out all nght. Maybe i've made a mistake with the variables i and np, any ideas? thanks
Code:#include <iostream>
using namespace std;
int main ()
{
struct member
{
char name[50];
}
member[10];
int choice = 0;
int np = 0; //Number of members on database
int i; // Member pointer
while (choice !=3)
{
cout<< "\nWhat would you like to do?";
cout<< "\n 1. Add a member";
cout<< "\n 2. View current members";
cout<< "\n 3. Exit";
cout<< "\n Choice: ";
cin>> choice;
cout<< "\n";
switch (choice)
{
case 1:
if (np < 10)
{
cout<< "Name: ";
cin>> member[np].name;
np = np + 1;
}
else
{
cout<< "The database is full!";
}
case 2:
i = np;
for (int i; i > 0; i--)
{
cout<< member[i].name;
}
}
}
}