So, I'm making a structure that works with videos that is supposed to import them from a txt file and I get an error on line 42(uninitialized local variable filme use) and I don't know how to fix it. I can't change Main
function.
Any help please ?
#include <iostream>
#include <fstream>
#include<string>
#include<vector>
using namespace std;
struct Filme {
public:
//string name;
int anu;
string denumire;
//int ani;
//vector<string>den;
};
void Import(int n, Filme* film,string den) {
ifstream ifs(den);
string denumire;
int anu;
while (!ifs.eof()) {
ifs >> denumire >> anu;
film->denumire = denumire;
film->anu = anu;
}
}
void Afisare(Filme *filme)
{
cout << filme->denumire<< endl;
cout << filme->anu << endl;
}
int main()
{
Filme* filme;
int n;
cout << "Cate filme doriti sa importati din fisier: ";
cin >> n;
Import(n, filme, "filme.txt");
//Sort(filme);
Afisare(filme);
return 0;
}