Dzień dobry, wpadłem na pomysł napisania prostego programu, który ma na celu zapamiętanie danych kilku użytkowników, a następnie wyświetlenie ich pełnych danych na podstawie jednej z nich np. pesel.
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
cout << "Dzien dobry." << endl;
string NRTEL;
string pesel;
string calosc;
string dane;
string firstName;
string lastName;
string PESEL;
string nrtel;
int wybor;
bool nieZamykac = true;
if( nieZamykac = false)
{
exit ( 1 );
}
do
{
cout << "1. Dodaj uzytkownika" << endl;
cout << "2. Wyswietl uzytkownikow" << endl;
cout << "3. Znajdz po numerze PESEL" << endl;
cout << "4. Znajdz po numerze tel." << endl;
cout << "5. Wyjscie" << endl;
cin >> wybor;
switch(wybor)
{
case 1:
system("cls");
cout << "Podaj imie uzytkownika: " << endl;
cin >> firstName;
system("cls");
cout << "Podaj nazwisko uzytkownika: " << endl;
cin >> lastName;
system("cls");
cout << "Podaj numer PESEL uzytkownika: " << endl;
cin >> PESEL;
system("cls");
cout << "Podaj numer telefonu uzytkownika: " << endl;
cin >> nrtel;
system ("cls");
dane = firstName + " " + lastName + " PESEL: " + PESEL + " Nr Telefonu: " + nrtel + "\n";
cout << dane << endl;
cout << "" << endl;
cout << "" << endl;
calosc = calosc + dane;
break;
case 2:
system("cls");
cout << calosc << endl;
cout << "" << endl;
cout << "" << endl;
break;
case 3:
system("cls");
cout << "Podaj PESEL w celu znalezienia uzytkownika: " << endl;
cin >> pesel;
system("cls");
if( pesel == PESEL )
{
cout << dane << endl;
cout << "" << endl;
cout << "" << endl;
}
else if( pesel != PESEL )
{
cout << "Nie znaleziono uzytkownika." << endl;
cout << "" << endl;
cout << "" << endl;
}
break;
case 4:
system("cls");
cout << "Podaj nr. telefonu w celu znalezienia uzytkownika: " << endl;
cin >> NRTEL;
system("cls");
if( NRTEL == nrtel )
{
cout << dane << endl;
cout << "" << endl;
cout << "" << endl;
}
else if( NRTEL != nrtel )
{
cout << "Nie znaleziono uzytkownika." << endl;
cout << "" << endl;
cout << "" << endl;
}
break;
case 5:
exit ( 1 );
}
} while( nieZamykac = true);
return 0;
}
Gdy uruchomię program i próbuję wyszukać użytkownika za pomocą numeru telefonu lub peselu, to komputer bierze pod uwagę jedynie ostatniego wpisanego użytkownika. Prosiłbym o pomoc.