Mam taki sobie nie dokończony kod. A po próbie debuggowania w okienku CMD wyskakuje mi taki o to błąd : "Process exited with return value 3221225477" . Dev-C++ nie znajduję żadnych problemów więc piszę tutaj.
Mogę nawet dokładniej określić błąd, jest w funkcji wyswietl(), gdy usuwam ten fragment wszystko ładnie działa. Z góry dzięki za pomoc.
#include <iostream>
#include <cmath>
#include <conio.h>
#include <string>
using namespace std;
const float PI = 3.14;
class Student{
string Imie;
string Nazwisko;
int Nr_albumu;
float Srednia;
int n;
string* Przedmioty;
public:
string wImie(){
return (Imie);
}
string wNazwisko(){
return (Nazwisko);
}
int wNr_albumu(){
return (Nr_albumu);
}
float wSrednia(){
return (Srednia);
}
void wPrzedmioty(){
for (int i=0;i<0;i++){
cout << i+1 << " Przedmiot to: "<< Przedmioty[i] <<endl;
}}
void wczytaj(){
cout << "Podaj: "<<endl;
cout << "Imie: ";
cin >> Imie;
cout << "Nazwisko: ";
cin >> Nazwisko ;
cout << "Nr Albumu: ";
cin >> Nr_albumu;
cout << "Srednia: ";
cin >> Srednia; cout << endl;
cout << "Ile chcesz wprowadzic przedmiotow? ";
cin >> n;
Przedmioty= new string[n];
for (int i=0; i<n; i++){
cout << i+1 << " Przedmiot: ";
cin >> Przedmioty[i];
}
}
void wyswietl(){
cout << Imie << " " << Nazwisko << endl;
cout << "Nr albumu: " << hex << Nr_albumu << endl;
cout << "Srednia: " << dec << Srednia << endl;
cout << "Przedmioty: " << endl;
for(int j=0; j<n ; j++)
{
cout << endl << j+1 <<". "<< Przedmioty[j];
}
}
};
int main ()
{
int IleStudentow;
Student* NowyStudent = new Student[IleStudentow];
cout << " Ile studentow chcesz wprowadzic? ";
cin >> IleStudentow; cout << endl;
int i=0;
for (i; i<IleStudentow; i++){
cout <<"Student nr."<< i+1 <<". ";
NowyStudent[i].wczytaj();
}
cout << "#############################################"<<endl;
cout << "# Wybierz opcje: #"<<endl;
cout << "# 1. Dodaj studenta. #"<<endl;
cout << "# 2. Wyswietl studentow. #"<<endl;
cout << "# 3. Przesli dane do pliku #"<<endl;
cout << "# 4. Usun dane i zamkni program #"<<endl;
cout << "#############################################"<<endl;
int wybor;
cin >> wybor;
int Dodaj = 0;
switch(wybor)
{
case 1:
cout << "Ilu studentow chcesz dodac? ";
cin >> Dodaj;
Dodaj=i+Dodaj;
IleStudentow=IleStudentow+Dodaj;
for (i;i<Dodaj;i++){
cout <<"Student nr."<< i+1 <<". ";
NowyStudent[i].wczytaj();
}
break;
case 2:
for (int k=0; k < IleStudentow; k++){
NowyStudent[k].wyswietl();
cout << endl;
}
break;
case 3:
cout <<"3";
break;
case 4:
cout <<"4";
break;
default:
cout << "Nie ma takiej opcji.";
}
cin.get();
return 0;
}