Re: Null-terminated strings: the final analysis.



On 12/04/09 20:16, Mark Wooding wrote:
Joe Wright<joewwright@xxxxxxxxxxx> writes:

I believe strings can contain tabs, and other things that don't print but I
agree strings cannot contain the NUL character.

... by a trivial consequence of C's definition of a string, no less.

Exactly - definitionally.

Further, a text file is corrupted by the NUL character in a line.

Only because C strings can't represent lines of text containing a zero
byte.

Again we're into definitions: my definition of a text file is one that doesn't contain non-alphanumeric characters. So if you send a null into such a file, its corrupted.

Using this to justify C's representative inadequacy is circular.

But then so is the counter-argument that is being made. C defines a string as a null-terminated array of characters, therefore its circular to complain that a string can't contain a null.

And anyway, if you want char arrays containing nulls, C can do those, no problem.

--
Mark McIntyre

CLC FAQ <http://c-faq.com/>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
.



Relevant Pages

  • Re: How to convert Infix notation to postfix notation
    ... If this is for an error message, why isn't it using stderr for its output? ... array of 15 characters, and you call this function with the limit 15 on ... Making sure that the only string I allocate and append to, ... because mulFactor in all versions must needs incorporate the functions ...
    (comp.lang.c)
  • Re: Prothon should not borrow Python strings!
    ... """It does not make sense to have a string without knowing what encoding ... same cul de sac as Python. ... Prothon_String_As_ASCII // raises error if there are high characters ... Python's split between byte strings and Unicode strings is ...
    (comp.lang.python)
  • Re: Letter to US Sen. Byron Dorgan re unpaid overtime
    ... put them in stupid places. ... Programming is difficult (as you must surely appreciate, ... > strings will be in the range 1...1000 characters. ... impose an artificially small limit on string length." ...
    (comp.programming)
  • Re: Byte Array to String
    ... retrieved text will mismatch the original characters. ... encoding the characters. ... Dim strFileData as String ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: A note on personal corruption as a result of using C
    ... impossible to write effective string validation routines by definition ... (Note that a string literal may contain embedded null characters; ... without resorting to abusive language. ... In practice, programmers typically use "struct" ...
    (comp.programming)