Kontoverwaltung

Bismark

Erfahrenes Mitglied
Hallo Leute,

ich habe ein Programm geschrieben, womit man Kontos verwalten kann.
Man soll damit ein Konto erstellen, die Daten einzelner Personen ausgeben kann, usw..
Das Problem liegt bei der Ausgabe der Daten einzelner Personen. Das Programm sucht zwar nach den Personen, aber es gibt nichts aus. Die jeweiligen "Menüpunkte" sind in Funktionen.

Code:
#include <conio.h>
#include <iostream>
#include <string>
#include "conioex.h"


using namespace std;



struct konto				//Def. Struckt
{
	string name;
	int kontonr;
	float kbetrag;
};

const int anz = 10;
konto liste[anz];

void kontoalg (konto liste[anz]);
void ausgeben (konto liste[anz]);



int main()										//Anfang Hauptprogramm
{
char wahl;

textcolor(GREEN);
textbackground(YELLOW);
	do
	{
	system ("cls");
		gotoxy(29,10);
		cout<<"#### M E N U E ####"<<endl<<endl;
		gotoxy(29,12);
		cout<<"<1> Konto Anlegen"<<endl;
		gotoxy(29,13);
		cout<<"<2> Daten Ausgeben"<<endl;
		cout<<"Ihre Wahl ==> ";
		cin>>wahl;


		switch (wahl)
		{
		case '1': kontoalg (liste);break;
		case '2':	ausgeben (liste);break;
		}
	}
	while(wahl != '#');

getch();

return 0;
}																				//Ende des Programms


void kontoalg(konto liste[anz])					// Funktionen				
{
	char antwort;
	int zae=0;


  
	do
	{
	system ("cls");
	gotoxy(29,10);
	cout<<"## KONTO ANLEGEN ##"<<endl<<endl;
	gotoxy(29,12);
	cout<<"Nachname: ";
	cin>>liste[zae].name;
	gotoxy(29,13);
	cout<<"Kontonr.: ";
	cin>>liste[zae].kontonr;

	liste[zae].kbetrag = 0;


	zae++;
	system ("cls");
	gotoxy(25,13);
	cout<<"Noch ein Konto anlegen? -j,J/n,N";
	cin>>antwort;


	}
	while(antwort == 'j' || antwort == 'J' && zae <= 10 );

}


void ausgeben (konto liste[anz])
{
char wahl;
string nam, tausch;
int merker, zahl, x = 0;


do
{
system ("cls");
gotoxy(29,10);
cout<<"#### Daten ausgeben ####"<<endl;
gotoxy(29,12);
cout<<"Von wem wollen sie die daten ausgeben?"<<endl;
gotoxy(29,14);
cout<<"Suchen nach:"<<endl;
gotoxy(29,15);
cout<<"<1> Nachname"<<endl;
gotoxy(29,16);
cout<<"<2> Kontonummer"<<endl;
gotoxy(29,17);
cout<<"<#> Ende"<<endl;
gotoxy(35,19);
cout<<"Wahl ==> ";
cin>>wahl;

	if(wahl=='1')
	{
		system ("cls");
		gotoxy(29,15);
		cout<<"Nachname: "<<endl;
		cin>>nam;

		do
		{
		merker = 0;
			for (int x = 0; x<anz-1;x++)
			{
				if (liste[x].name == nam)
				{
				cout<<liste[x].name<<endl;
				cout<<liste[x].kontonr<<endl;
				cout<<liste[x].kbetrag<<endl;
				merker = 1;
				x++;
				}
			}
		}
		while (merker == 0 && x<10);
	}
		
		if (wahl == '2')
		 {
				cout<<"Kontonummer: "<<endl;
				cin>>zahl;

				do
				{
				merker = 0;
					for (int x = 0; x<anz-1;x++)
					{
						if (liste[x].kontonr == zahl)
						{
						cout<<liste[x].name<<endl;
						cout<<liste[x].kontonr<<endl;
						cout<<liste[x].kbetrag<<endl;
						merker = 1;
						}
					}
				}
				while (merker == 0);
		 }  
}
while (wahl != '#');
}
 
Zuletzt bearbeitet:
Hast du schon einmal über en Befehl system ("cls"); nachgedacht?
Dein Programm macht die Ausgabe wie du sie haben möchtest nur innerhalb eines Bruchteils einer Sekunde wird die Ausgabe gelöscht.

Code:
void ausgeben (konto liste[anz])
{
char wahl, q;
string nam, tausch;
int merker, zahl, x = 0;


do
{
system ("cls");
gotoxy(29,10);
cout<<"#### Daten ausgeben ####"<<endl;
gotoxy(29,12);
cout<<"Von wem wollen sie die daten ausgeben?"<<endl;
gotoxy(29,14);
cout<<"Suchen nach:"<<endl;
gotoxy(29,15);
cout<<"<1> Nachname"<<endl;
gotoxy(29,16);
cout<<"<2> Kontonummer"<<endl;
gotoxy(29,17);
cout<<"<#> Ende"<<endl;
gotoxy(35,19);
cout<<"Wahl ==> ";
cin>>wahl;

	if(wahl=='1')
	{
		system ("cls");
		gotoxy(29,15);
		cout<<"Nachname: "<<endl;
		cin>>nam;

		do
		{
		merker = 0;
			for (int x = 0; x<anz-1;x++)
			{
				if (liste[x].name == nam)
				{
				cout<<liste[x].name<<endl;
				cout<<liste[x].kontonr<<endl;
				cout<<liste[x].kbetrag<<endl;
				merker = 1;
				x++;
				system("pause");
				}
			}
		}
		while (merker == 0 && x<10);
	}
		
		if (wahl == '2')
		 {
				cout<<"Kontonummer: "<<endl;
				cin>>zahl;

				do
				{
				merker = 0;
					for (int x = 0; x<anz-1;x++)
					{
						if (liste[x].kontonr == zahl)
						{
						cout<<liste[x].name<<endl;
						cout<<liste[x].kontonr<<endl;
						cout<<liste[x].kbetrag<<endl;
						merker = 1;
						system("pause");
						}
					}
				}
				while (merker == 0);
		 }  
}
while (wahl != '#');

}

Ich habe jetzt mal provisorisch ein system("pause"); an die kritischen Stellen geschrieben.
Musst dir eben überlegen wie es seien soll.
 
ich habe ein Problem und zwar mit dem Speichern und Laden.

Ich habe die nötigen Codes geschrieben, damit die Daten die ich während des laufenden Programms eingebe, gespeichert und beim öffnen des Programms wieder zu Verfügung stehen. Ich habe nur den relevanten teil des Programms ins Thread kopiert, da es sehr groß ist.

Ich habe die Stellen Markiert

Code:
#include <conio.h>
#include <iostream>
#include <fstream>
#include <string>
#include "conioex.h"


using namespace std;



struct konto				//Def. Struckt
{
	string name;
	int kontonr;
	float kbetrag;
};

const int anz = 10;
konto liste[anz];

void kontoalg (konto liste[anz]);
void eazahl (konto liste[anz]);
void ausgeben (konto liste[anz]);
//int andern (konto liste[anz]);
//int loschen (konto liste[anz]);




int main()													//Anfang Hauptprogramm
{
char wahl;

textcolor(GREEN);
textbackground(YELLOW);
	do
	{
	system ("cls");
		gotoxy(29,10);
		cout<<"#### M E N U E ####"<<endl<<endl;
		gotoxy(29,12);
		cout<<"<1> Konto Anlegen"<<endl;
		gotoxy(29,13);
		cout<<"<2> Ein-/Auszahlung"<<endl;
		gotoxy(29,14);
		cout<<"<3> Daten Ausgeben"<<endl;
		gotoxy(29,15);
		cout<<"<4> Daten aendern"<<endl;
		gotoxy(29,16);
		cout<<"<5> Konto Loeschen"<<endl;
		gotoxy(29,17);
		cout<<"<#> Programm beenden"<<endl;
		gotoxy(43,19);
		cout<<"Ihre Wahl ==> ";
		cin>>wahl;


		switch (wahl)
		{
		case '1': kontoalg (liste);break;
	        case '2': eazahl (liste);break;
		case '3': ausgeben (liste);break;
		}
	}
	while(wahl != '#');

getch();

return 0;
}																				//Ende des Programms


void kontoalg(konto liste[anz])								
{
	char antwort;
	int zae=0, z=0;
	bool merker;


  
	do
	{
	system ("cls");
	gotoxy(29,10);
	cout<<"## KONTO ANLEGEN ##"<<endl<<endl;
	gotoxy(29,12);
	cout<<"Nachname: ";
	cin>>liste[zae].name;
	gotoxy(29,13);
	cout<<"Kontonr.: ";
	cin>>liste[zae].kontonr;
	gotoxy(29,14);
	cout<<"Kontostand: ";
	cin>>liste[zae].kbetrag;

	ofstream dataus;                                                    //Anfang Speichern
	dataus.open("konten.txt", ios::out);
	
	for(int y=0;y <anz;y++)
	{
		dataus<<liste[y].name<<" ";
		dataus<<liste[y].kontonr<<" ";
		dataus<<liste[y].kbetrag<<endl;
	}
	dataus.close();                                                     //Ende Speichern

	ifstream datin;                                                      //Anfang Laden
	datin.open("konten.txt", ios::in);
	
	for(int y=0;!datin.eof();y++)
	{
	datin>>liste[y].name<<" ";
	datin>>liste[y].kontonr<<" ";
	datin>>liste[y].kbetrag<<endl;
	}
	datin.close();                                                      //Ende Laden


	zae++;
	system ("cls");
	gotoxy(25,13);
	cout<<"Noch ein Konto anlegen? -j,J/n,N";
	cin>>antwort;


	}
	while(antwort == 'j' || antwort == 'J' && zae < 10 );

}


Ich Hoffe ihr könnt mir helfen
 
Zuletzt bearbeitet:
Zurück