Studentlist

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
  #include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>



using namespace std;

struct student
{
	string fName; 
	string vName; 
	int matrNr; 
	bool matrNrOK(int matrNummer)
	{
		if (matrNummer > 999999)
			return true;
		else
			return false;
	}
	bool nameOK(string name)
	{
		if (name.length() > 0)
			return true;
		else
			return false;
	}
};

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.
Last edited on
Ok. I was abel to fix it by my self. i think its without bugs. But please try it out and if find glitches please help me ti fix them.

Thanks
Topic archived. No new replies allowed.