Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Richard Harnden Newsgroups: comp.lang.c Subject: Re: question about nullptr Date: Fri, 12 Jul 2024 14:19:19 +0100 Organization: A noiseless patient Spider Lines: 27 Message-ID: References: <20240706054641.175@kylheku.com> Reply-To: nospam.harnden@invalid.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 12 Jul 2024 15:19:19 +0200 (CEST) Injection-Info: dont-email.me; posting-host="dabe62a38bca590dd76a1c83da45a0e3"; logging-data="3187465"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/L0VYiI9ZuEviO2wow4RH6u3YtoJ5hhd0=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:inzCC4kQwcLncQcvVolzYvwi5aI= Content-Language: en-GB In-Reply-To: <20240706054641.175@kylheku.com> Bytes: 1947 On 06/07/2024 13:54, Kaz Kylheku wrote: > On 2024-07-06, Thiago Adams wrote: >> If you were creating C code today and could use a C23 compiler, would >> you use nullptr instead of NULL? > > In greenfield projects under my dictatorship, I use 0, as in: > > char *p = 0; > > I was still 20 something when I (easily) wrapped my head around the 0 > null pointer constant, and have not had any problems with it. > Once I learned the standard-defined truth about null pointer constants, > and their relationship to the NULL macro, I dropped NULL like a hot > potato, and didn't look back (except when working in code bases that use > NULL). > I don't understand why you wouldn't use NULL. If it's a pointer: NULL If it's an integer: 0 If it's a double: 0.0 If it's a char: '\0' Don't you use '\n'? Surely nobody would say 0x0a?