Witam Państwa od razu przejdę do sedna sprawy.
chodzi o U
Ma usuwać z tablicy studenta o przykładowym podanym numerze od 1 do 100 ale numery jakieś dziwne mi się wpisują do tablicy numer, no i usuwanie polega na tym że przesuwać ma innych studentów o jedno w górę co też nie wychodzi bo przesuwa od pierwszego w tablicy
#include <iostream>
#include <fstream>
using namespace std;
class Student
{
char Imie [16];
char Nazwisko [16];
public:
friend
istream& operator >> (istream& klawiatura, Student& student);
friend
ostream& operator << (ostream& monitor, Student& student);
friend
ifstream& operator >> (ifstream& wejscie, Student& student);
friend
ofstream& operator << (ofstream& wysjcie, Student& student);
};
istream& operator >> (istream& klawiatura, Student& student )
{
cout << "Imie studenta: " << flush;
klawiatura >> student.Imie;
cout << "Nazwisko studenta: " << flush;
klawiatura >> student.Nazwisko;
return klawiatura;
}
ostream& operator << (ostream& monitor, Student& student)
{
monitor << "Imie studenta: " << flush;
monitor << student.Imie << endl;
monitor << "Nazwisko studenta: " << flush;
monitor << student.Nazwisko << endl;
return monitor;
}
ifstream& operator >> (ifstream& wejscie, Student& student)
{
wejscie >> student.Imie;
wejscie >> student.Nazwisko;
return wejscie;
}
ofstream& operator << (ofstream& wyjscie, Student& student)
{
wyjscie << student.Imie << ' ';
wyjscie << student.Nazwisko << ' ';
wyjscie << endl;
return wyjscie;
}
int main()
{
Student Ewidencja [100];
int i, puste=0, numer[100];
bool dalej=true;
char pole;
ifstream Uczelnia;
ofstream Uczelnia1;
while(dalej)
{
cout<<endl<<"Podaj polecenie [N,W,U,Z,O,Q]: ";
cin >> pole;
switch (pole & 0x5F)
{
case 'N' : if(puste==100) cout<<"Brak miejsc w tabeli."<<endl;
else
{
cout<<endl;
cin >> Ewidencja[puste++];
}
break;
case 'W' : cout<<endl;
for(i=0; i<puste; i++)
cout <<numer[i]<<" "<< Ewidencja[i];
break;
case 'U' : cout<<endl;
for(i=0; i<puste; i++)
cout << "Podaj numer studenta którego chcesz usunąć: " << flush;
cin >> numer[i];
cout << Ewidencja[i+1];
break;
case 'Z' : cout<<endl;
Uczelnia1.open("Uczelnia.txt", ios::in);
for(i=0; i < puste;i++)
Uczelnia1 << Ewidencja[i];
cout << "Zapisano. "<<endl;
break;
case 'O' : cout<<endl;
Uczelnia.open("Uczelnia.txt", ios::out);
for(i=0; i < puste; i++)
Uczelnia >> Ewidencja[i];
cout <<"Odczytano. "<<endl;
break;
case 'Q' : dalej=false;
break;
default : cout<<"Bledne polecenie. "<<endl;
}
}
cout<<endl<<"Nacisnij ENTER aby zakonczyc program.";
cin.get();
cin.ignore();
}