From: "Charlie Gordon" <gmane@chqrlie.org>
To: linux-c-programming@vger.kernel.org
Subject: Re: value computed is not used ??
Date: Tue, 1 Jun 2004 09:30:57 +0200 [thread overview]
Message-ID: <c9hb7s$3o1$1@sea.gmane.org> (raw)
In-Reply-To: Pine.LNX.4.21.0406010333220.1813-100000@hestia
Let's do code review :
> #include <stdio.h>
>
> int main(void) {
this is not a the correct propotype for main.
> char *ptr = NULL;
this initialization is useless.
> char str[] = "whats up";
what a horrible thing to write : this effectively defines an automatic
char array that gets initialized by copying the string "what's up".
while this is fine for global data, it is very inefficient for automatic
variables.
a better way would be:
const char *str = "whats up";
const char *ptr;
>
> for(ptr = str; *ptr; *ptr++) {
*ptr++ is causing the warning "value computed not used"
ptr++ suffices.
> printf("%c", *ptr);
for completeness, let it be known that some snoddy compilers will complain
that the result of printf is not used.
why not write:
putchar(*ptr);
> }
>
> printf("\n");
same as above:
putchar('\n');
> return 0;
> }
rework needed on 7 out of 8 non empty lines.
amazingly, there doesn't seem to be any algorithmic flaw in this simplistic
program.
Hope is helps.
Chqrlie.
next prev parent reply other threads:[~2004-06-01 7:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-23 23:05 functions to determine dementions of console? ameer armaly
2004-05-24 2:09 ` Glynn Clements
2004-05-26 14:41 ` Christoph Bussenius
2004-05-30 19:12 ` J.
2004-05-30 20:35 ` Micha Feigin
2004-05-31 19:38 ` Christoph Bussenius
2004-06-01 1:41 ` value computed is not used ?? J.
2004-06-01 3:25 ` Glynn Clements
2004-06-01 7:30 ` Charlie Gordon [this message]
2004-06-01 16:08 ` Charlie Gordon
2004-06-01 21:58 ` Glynn Clements
2004-06-03 1:26 ` Micha Feigin
-- strict thread matches above, loose matches on Subject: below --
2004-06-01 17:34 Huber, George K RDECOM CERDEC STCD SRI
2004-06-01 19:09 ` Glynn Clements
2004-06-01 20:58 ` Charlie Gordon
2004-06-01 21:44 ` Glynn Clements
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='c9hb7s$3o1$1@sea.gmane.org' \
--to=gmane@chqrlie.org \
--cc=linux-c-programming@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.