?
Kyle schrieb:
Weil ios::out dazu neigt die komplette Datei zu überschreiben und nicht nur ein einzelnes Zeichen.
Deswegen sagte ich ja "ios::in|ios::out"
Du öffnest die Datei einmal zum Lesen und Schreiben und lässt sie dann während der Arbeit geöffnet.
*zitiert aus der MDSN*
nMode
An integer that contains mode bits defined as ios enumerators that can be combined with the bitwise OR ( | ) operator. The nMode parameter must have one of the following values:
ios::app The function performs a seek to the end of file. When new bytes are written to the file, they are always appended to the end, even if the position is moved with the ostream::seekp function.
ios::ate The function performs a seek to the end of file. When the first new byte is written to the file, it is appended to the end, but when subsequent bytes are written, they are written to the current position.
ios::in The file is opened for input. The original file (if it exists) will not be truncated.
ios::out The file is opened for output.
ios::trunc If the file already exists, its contents are discarded. This mode is implied if ios::out is specified, and ios::ate, ios::app, and ios:in are not specified.
ios::nocreate If the file does not already exist, the function fails.
ios::noreplace If the file already exists, the function fails.
ios::binary Opens the file in binary mode (the default is text mode).
Note that there is no ios::in or ios::out default mode for fstream objects. You must specify both modes if your fstream object must both read and write files.