Witam, pisze tekstową gre na zaliczenie. Niestety na starcie po wpisaniu nazwy gracza gra sie wysypuje. Gdzie zrobiłem błąd?
Nie wydaje mi się, że to błąd fstream (który wyświetla intro gry) tylko bardziej chodzi o vector. ( funkcja void jest wywoływana w case 1 w menu) WELP
#include <iostream>
#include <fstream>
#include <windows.h>
#include <string>
#include <vector>
using namespace std;
struct Character // postac i jej statystyki
{
string name;
};
vector <Character> postac;
void charcre(vector <Character> postac)
{
string name;
system("cls");
cout << "o==[]::::::::::::::::> TWORZENIE POSTACI <::::::::::::::::[]==O" << endl;
cout << "---------------------------------------------------------------" << endl;
cout << endl;
cout << " IMIE TWOJEJ POSTACI: ";
cin >> postac[1].name ;
getchar();
ifstream plik;
plik.open("charcre_intro.txt");
char output[1000];
if (plik.is_open())
{
while (!plik.eof())
{
plik >> output;
cout<<output;
}
}
}
int main()
{
vector <Character> postac;
int wybormenu;
cout << "o==[]::::::::::::::::> SUPER GRA FANTASY 3 <::::::::::::::::[]==O" << endl;
cout << "---------------------- MENU GLOWNE ----------------------" << endl;
cout << " 1. GRAJ " << endl;
cout << " 2. WYJDZ " << endl;
cout << " WYBOR: "; cin >> wybormenu;
switch(wybormenu)
{
case 1:
charcre(postac);
getchar();
cout << " XXX " << endl;
cout << " XXX " << endl;
cout << " XXX " << postac[1].name << endl;
break;
case 2:
exit(0);
break;
}
return 0;
}