From: Branko Cibej <branko.cibej@hermes.si>
To: Peter Seebach <seebs@monolith.solon.com>
Cc: egcs@cygnus.com
Subject: Make Money Fast (was: Re: linux libio status)
Date: Thu, 16 Oct 1997 02:35:00 -0000 [thread overview]
Message-ID: <3445B57B.EAAF8231@hermes.si> (raw)
In-Reply-To: <199710151909.OAA21070@monolith.solon.com>
Peter Seebach wrote:
> However, correctness aside, it is good to use NULL for null pointers,
> for the same reason it is good to use "hello, world" rather than
> { 'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd' }
> to initialize arrays of characters.
>
> (One point extra credit for spotting the difference, two points
> extra credit for spotting the case where the two are not different.)
Here you are, then:
/* sizeof(diff1) == sizeof(diff2) + sizeof('\0') */
char diff1[] = "hello, world";
char diff2[] = { 'h', 'e', 'l', 'l', 'o', ',',
' ', 'w', 'o', 'r', 'l', 'd' };
/* sizeof(same1) == sizeof(same2) == sizeof(diff2) */
char same1[12] = "hello, world";
char same2[12] = { 'h', 'e', 'l', 'l', 'o', ',',
' ', 'w', 'o', 'r', 'l', 'd' };
(Who said you couldn't get free credit over the Net? :-)
--
Branko Cibej <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
phone: (++386 61) 186 53 49 fax: (++386 61) 186 52 70
next prev parent reply other threads:[~1997-10-16 2:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <199710150623.XAA06491.cygnus.egcs@atrus.synopsys.com>
1997-10-15 2:10 ` linux libio status Jason Merrill
1997-10-15 9:15 ` Joe Buck
1997-10-15 11:12 ` Per Bothner
1997-10-15 14:33 ` Joe Buck
1997-10-15 16:51 ` Per Bothner
[not found] ` <199710152351.QAA02138.cygnus.egcs@cygnus.com>
1997-10-16 1:51 ` Jason Merrill
1997-10-16 12:58 ` Alexandre Oliva
1997-10-16 12:58 ` Joe Buck
1997-10-17 12:53 ` Jason Merrill
1997-10-15 16:51 ` Peter Seebach
1997-10-16 2:35 ` Branko Cibej [this message]
1997-10-15 14:33 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3445B57B.EAAF8231@hermes.si \
--to=branko.cibej@hermes.si \
--cc=egcs@cygnus.com \
--cc=seebs@monolith.solon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).