Por cierto, también hay un pequeño error, que es que desde el "nombre de la pelicula" hasta "subtitulos?" los datos de sus respectivas preguntas son de la primera pelicula, pero después, a partir de "minutos", los datos los recoge de la última película que puse.
Código
Repito, lo único que me falla es la parte en el que el programa tiene que leer la información que hay en el fichero, es decir, la del inputFile.
#include <iostream> #include <string> using namespace std; #include <fstream> #include <iomanip> #include <cctype> typedef enum { action, adventure, scifi, comedy, drama, mystery, horror } tGenre; typedef enum { spanish, english, french, german, italian, portuguese } tLanguage; tGenre readGenre(); string genreToStr(tGenre genre); tLanguage readLanguage(); string languageToStr(tLanguage lang); int main() { string gen; string language; string str; string nif; string date; string title; string director; tGenre genre; tLanguage lang; int minutes; int days; char aux; char result; bool subtitles = true; ofstream outputFile; ifstream inputFile; outputFile.open("rentals.txt",ios::out); do { cout << "Film title (# to end): "; cin.sync(); getline(cin, title); if (title != "#" ) { outputFile << title << endl; cout << "Film director: "; cin.sync(); getline (cin, director); outputFile << director << endl; genre = readGenre(); gen = genreToStr(genre); outputFile << gen << endl; lang = readLanguage(); language = languageToStr(lang); outputFile << language << endl; cout << "Film with subtitles (y/n)?: "; cin >> aux; aux = toupper (aux); if (aux == 'Y') { outputFile << aux << endl; outputFile << true << endl; subtitles = false; } else { subtitles = true; } cout << "Minutes: "; cin.sync(); cin >> minutes; outputFile << minutes << endl; cout << "Client NIF: "; cin.ignore(); cin >> nif; outputFile << nif << endl; cout << "Rental Date: "; cin.sync(); cin >> date; outputFile << date << endl; cout << "Rental Days: "; cin.sync(); cin >> days; outputFile << days << endl; } } while (title != "#"); outputFile << "#" << endl; inputFile.open("rentals.txt",ios::in); while (!inputFile.eof() && aux == 'Y' || aux == 'N') { int rental; getline(inputFile, title); getline(inputFile, director); getline(inputFile, gen); getline(inputFile, language); inputFile >> subtitles; inputFile >> minutes; getline(inputFile, nif); getline(inputFile, date); inputFile >> days; switch (aux) { case 'Y': if (subtitles == false) { rental = ++rental; cout << "Rental " << rental << endl; cout << title << " (" << director << "), " << gen << ", " << language << " (subt. Spanish), " << minutes << " min." << endl; cout << "Client: " << nif << " - " << date << ", " << days << " days" << endl; subtitles = true; } break; case 'N': if (subtitles == true) { rental = ++rental; cout << "Rental " << rental << endl; cout << title << " (" << director << "), " << gen << ", " << language << ", " << minutes << " min." << endl; cout << "Client: " << nif << " - " << date << ", " << days << " days" << endl; subtitles == false; break; } default: exit(1); } } inputFile.close(); outputFile.close(); return 0; }