Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C String terminator Date: Wed, 15 Jan 2020 10:52:23 -0800 Organization: None to speak of Lines: 28 Message-ID: <87imlcimc8.fsf@nosuchdomain.example.com> References: <303beb4a-dd99-4dbd-bbb7-eb8a07632526@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="23486d94539f418d97196cbf14aeb35e"; logging-data="10683"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185CY5KK/EOOH+FsItFWAds" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:ZDIhn/pAw2jTBZOVa9zTerS5tp0= sha1:GcX7hQ3bjJeEpMYz/lua7NEKBzA= Xref: csiph.com comp.lang.c:149154 Malcolm McLean writes: [...] > Generally when we use the term "C string" we mean a nul-terminated string > with 8 bit characters, or coded in UTF-8. The C standard's actual definition of "string" has been quoted several times in this thread. > However the C language allows you to construct strings in memory which are > not nul terminated. No, the C language allows you to construct contiguous sequences of characters which are not nul terminated. Such a sequence is by definition not a string. > These won't work as expected with printf() or any > of the other C string handling functions. However you can write alternatives > to these functions that operate on counted strings, or whatever > alternative you have chosen. printf() and other C string handling functions have undefined behavior if passed a pointer that doesn't point to a string. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com [Note updated email address] Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */