ist da ein newline zeichen in dem string? wie hast du die datei geschrieben, als textdatei!? windows stellt zeilenumbrüche in textdateien als \r\n dar...
nein, die daten werden binär gespeichert und binär geladen. bei den direkt mit std::string "name" eingetragenen namen gibt es auch kein Problem. Es hängt offensichtlich mit der texteingabe über den Nutzer zusammen, über den der string dann erzeugt wird. Ich verwende SFML und vermute das dort dann über die wandlung von sf:
tring nach std::string die \r mit eingebaut wird.
als etwas unschönen workaround hab ich das jetzt folgendermaßen gelöst, dass "\r" einfach durch 2x "" ersetzt wird.
Das funktioniert soweit auch.
Danke für deine Hilfe.
Gruss
|
C-/C++-Quelltext
|
1
2
3
4
5
|
int pos=static_cast<int>(tempName.find("\r",0));
if(pos!=string::npos)
{
tempName.replace(pos,2,"",2);
}
|
-->
Loading Highscore List...
nElements: 10
Groesse LesePuffer: 133
Name: chucky Score: 10200 IndexCount: 8
Name: Miraculix Score: 6800 IndexCount: 20
Name: woodstock Score: 4500 IndexCount: 35
Name: hobbes Score: 2600 IndexCount: 50
Name: Nepomuk Score: 2300 IndexCount: 62
Name: tweety Score: 2300 IndexCount: 75
Name: sylvester Score: 1600 IndexCount: 87
Name: tom Score: 1300 IndexCount: 102
Name: snoopy Score: 1200 IndexCount: 111
Name: godzilla Score: 1100 IndexCount: 123
OK!
Enter GameLoop