Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
// open existing highscore file ifstream Input("Highscore.txt"); // if file open read it and copy the data to the vector list "highscore" if (Input.is_open() == true) { highscore.clear(); // clear vector list to read in the file data istream_iterator<int> begin(Input); // start iterator to file istream_iterator<int> end; // end iterator to file copy(begin, end, back_inserter(highscore)); // read the file <= DIESE ZEILE GENERIERT EINE FEHLERMELDUNG } else cout << "Datei \"Highscore.txt\" nicht gefunden." << endl; // create/open highscore file ofstream Output("Highscore.txt"); // save highscore list to file copy(highscore.rbegin(), highscore.rend(), ostream_iterator<int>(Output, " ")); // <= DIESE ZEILE GENERIERT EINE FEHLERMELDUNG Output.close(); // close highscore file |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 |
template<class _InIt, class _OutIt> inline _OutIt _Copy_impl(_InIt _First, _InIt _Last, _OutIt _Dest, _Nonscalar_ptr_iterator_tag) { // copy [_First, _Last) to [_Dest, ...), arbitrary iterators for (; _First != _Last; ++_Dest, ++_First) *_Dest = *_First; // <= DAS IST DIE ZEILE DIE IN DER FEHLERMELDUNG GENANNT WIRD return (_Dest); } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »iSmokiieZz« (07.10.2014, 22:54)
highscore ist vom Typ vector<Splayer> highscore; und nicht int, wie es deine Iteratoren sind. Das kannst du nicht kopieren.
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
// open existing highscore file ifstream Input("Highscore.txt"); // if file open read it and copy the data to the vector list "highscore" if (Input.is_open() == true) { highscore.clear(); // clear vector list to read in the file data istream_iterator<Splayer> begin(Input); // start iterator to file istream_iterator<Splayer> end; // end iterator to file copy(begin, end, back_inserter(highscore)); // read the file } else cout << "Datei \"Highscore.txt\" nicht gefunden." << endl; // create/open highscore file ofstream Output("Highscore.txt"); // save highscore list to file copy(highscore.rbegin(), highscore.rend(), ostream_iterator<Splayer>(Output, " ")); Output.close(); // close highscore file |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Hat Splayer einen passenden ">>" operator? Wenn nicht, wird das mit dem "istream_iterator" nicht klappen.
Werbeanzeige