B
Optimizer schrieb:
Bashar schrieb:
Stellt sich nur die Frage, ob man als letztes noch eine vollkommen leere Zeile der Länge 0 haben muss,
Das ist keine Zeile.
Beweise es. Wenn ich in einem beliebigen Texteditor in diese nicht-Zeile gehe, wird mir deren Nummer angezeigt.
Auf deutsch, du gehst in 2 bis 3 Texteditoren, die du kennst, in diese Zeile ... tolle Begründung.
Mein C#-Code compiliert, obwohl die letzte nicht-Zeile kein LF hat (aber nicht unwichtig für die Korrektheit des Codes ist).
Wir reden doch über C++, oder nicht? Meditier mal über folgenden Ausschnitt aus dem C99-Draft:
7.19.2 Streams
[#1] Input and output, whether to or from physical devices
such as terminals and tape drives, or whether to or from
files supported on structured storage devices, are mapped
into logical data streams, whose properties are more uniform
than their various inputs and outputs. Two forms of mapping
are supported, for text streams and for binary streams.209)
[#2] A text stream is an ordered sequence of characters
composed into lines, each line consisting of zero or more
characters plus a terminating new-line character. Whether
the last line requires a terminating new-line character is
implementation-defined. Characters may have to be added,
altered, or deleted on input and output to conform to
differing conventions for representing text in the host
environment. Thus, there need not be a one-to-one
correspondence between the characters in a stream and those
in the external representation. Data read in from a text
stream will necessarily compare equal to the data that were
____________________
209An implementation need not distinguish between text
streams and binary streams. In such an implementation,
there need be no new-line characters in a text stream nor
any limit to the length of a line.
7.19.1 Library 7.19.2
WG14/N869 Committee Draft -- January 18, 1999 299
earlier written out to that stream only if: the data consist |
only of printing characters and the control characters
horizontal tab and new-line; no new-line character is
immediately preceded by space characters; and the last
character is a new-line character. Whether space characters
that are written out immediately before a new-line character
appear when read in is implementation-defined.
Du wirst feststellen, dass der C-Standard sich große Mühe gibt, die exotischsten Textstreamformate zu unterstützen, denk z.B. an Lochkarten und dergleichen. Und von dem Standpunkt aus gesehen, von kleinstem gemeinsamen Nenner, ist meine Aussage gemeint.