#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
usingnamespace std;
struct student
{
string fName;
string vName;
int matrNr;
bool matrNrOK(int matrNummer)
{
if (matrNummer > 999999)
returntrue;
elsereturnfalse;
}
bool nameOK(string name)
{
if (name.length() > 0)
returntrue;
elsereturnfalse;
}
};
void insert(student pFeld[], student ds, int &aktAnz);
void output(student pFeld[], int aktAnz);
int main(void)
{
std::locale::global(std::locale("German_germany"));
int ANZ = 0;
char input;
int aktAnz = 0;
student *pFeld = NULL;
while (true)
{
cout << "What do you wnat to do?\n" << endl;
cout << "o --> How many Data of students do you wants tu put in? (f/F)\n: " << endl;
cout << "o --> Put in the datas (e/E)\n" << endl;
cout << "o --> Output of the Studentdata (a/A)\n" << endl;
cout << "o --> Quit (b/B)\n" << endl;
cin >> input;
switch (input)
{
case'f':
case'F':
{
system("cls");
cout << "\nHow many Data of students do you wants tu put in?: ";
cin >> ANZ;
if (ANZ <= 0)
{
do{
cout << "Invalid number: ";
cin >> ANZ;
} while (ANZ <= 0);
}
else
{
pFeld = new student[ANZ];
}
break;
}
case'e':
case'E':
{
student ds;
system("cls");
if (ANZ > 0 && aktAnz < ANZ)
{
cout << "\n Name: ";
cin >> ds.fName;
cout << "\n First Name: ";
cin >> ds.vName;
cout << "\n Number: ";
cin >> ds.matrNr;
if (ds.matrNrOK(ds.matrNr) && ds.nameOK(ds.fName))
{
insert(pFeld, ds, aktAnz);
}
else
{
while (ds.matrNr < 99999)
{
cout << "\n Invalid input! There has to be 6 digits. Please try again: ";
cin >> ds.matrNr;
insert(pFeld, ds, aktAnz);
}
}
}
break;
}
case'a':
case'A':
{
system("cls");
output(pFeld, aktAnz);
cout << endl << endl;
system("pause");
break;
}
case'b':
case'B':
{
system("cls");
delete[]pFeld;
return 0;
break;
}
}
}
return 0;
}
void insert(student pFeld[], student ds, int &aktAnz)
{
pFeld[aktAnz].fName = ds.fName;
pFeld[aktAnz].vName = ds.vName;
pFeld[aktAnz].matrNr = ds.matrNr;
aktAnz++;
}
void output(student pFeld[], int aktAnz)
{
cout << setw(10) << "Name" << setw(10) << "first Name" << setw(10) << "Number" << setw(10) << endl << endl;
for (int i = 0; i < aktAnz; i++)
{
cout << setw(10) << pFeld[i].fName << setw(10) << pFeld[i].vName << setw(10) << pFeld[i].matrNr << setw(10) << endl << endl;
}
}
Hello guys. i need some Help again. I realy tried to solve it by my self but I cant fix the bugs. This programm supose to to create data of student. It ask me how many, then it ask me about name and the number. If I put it all in it stops. Please help. I have to finisch it until tomorrow and I allready worked on it the hole weekend.