Patricia schrieb:
> Gibt es irgendeine Regelung in der Programmiersprache C, die besagt,
> dass man bei einer Ausgabe (stdout) die Escape Sequenz \n erst am Ende
> der Zeile schreiben muss?
Das ist etwas merkwürdig formuliert, denn es ist eher umgekehrt. Wenn du
irgendwo \n schreibst, wird das automatisch als Zeilenende
interpretiert. Damit ergibt sich von selbst, daß \n erst am Ende der
Zeile ist. Wenn danach noch was kommt, steht das halt in der nächsten
Zeile.
Karl Heinz Buchegger schrieb:
> Es gibt nur eine Regelung:
> Wenn die stdout gepuffert ist, UND ein \n ausgegeben wird, DANN muss
> dieser Puffer vom I/O System geleert werden.
Aber auch nur, wenn es "line buffered" ist.
Karl Heinz Buchegger schrieb:
>> Eine generelle Frage noch: Wie wird eigentlich der stdout gepuffert?
>
> Das entscheidet dein I/O System.
> C an sich interessiert sich nicht dafür
Das stimmt nicht ganz. Es gibt sogar eine Standard-Funktion um das
Buffering umzustellen, auch wenn das nicht zwingend von jeder Plattform
untestützt werden muss. Hier mal ein Auszug aus C99:
*******************************************************************
When a stream is unbuffered, characters are intended to appear from the
source or at the destination as soon as possible. Otherwise characters
may be accumulated and transmitted to or from the host environment as a
block. When a stream is fully buffered, characters are intended to be
transmitted to or from the host environment as a block when a buffer is
filled. When a stream is line buffered, characters are intended to be
transmitted to or from the host environment as a block when a new-line
character is
encountered. Furthermore, characters are intended to be transmitted as a
block to the host environment when a buffer is filled, when input is
requested on an unbuffered stream, or when input is requested on a line
buffered stream that requires the transmission of characters from the
host environment. Support for these characteristics is
implementation-defined, and may be affected via the setbuf and setvbuf
functions.
*******************************************************************