Re: Yet another pointer related problem
From: Dan Pop (Dan.Pop_at_cern.ch)
Date: 03/03/04
- Next message: Martin Dickopp: "[OT] Re: Freestanding Environment"
- Previous message: pete: "Re: Arithmetic and C"
- In reply to: Grumble: "Re: Yet another pointer related problem"
- Next in thread: CBFalconer: "Re: Yet another pointer related problem"
- Reply: CBFalconer: "Re: Yet another pointer related problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 3 Mar 2004 13:54:30 GMT
In <c24e34$53j$1@news-rocq.inria.fr> Grumble <invalid@kma.eu.org> writes:
>sugaray wrote:
>
>> The purpose of the following program is to store all the arguments
>> passed to main() into an array of char, and print'em out onto the
>> screen.
>
>#include <stdio.h>
>
>int main(int argc, char **argv)
>{
> char **p;
>
> for (p = argv; *p != NULL; ++p) puts(*p);
>
> return 0;
>}
>
>or
>
>#include <stdio.h>
>
>int main(int argc, char **argv)
>{
> int i;
>
> for (i=0; i < argc; ++i) puts(argv[i]);
>
> return 0;
>}
Two examples of wasteful programs that can be combined into an
environmentally friendly one:
#include <stdio.h>
int main(int argc, char **argv)
{
while (*argv) puts(*argv++);
return 0;
}
Dan :-)
P.S. This example and the canonical strcpy loop are at the limit of
what I consider readable C code. People who don't understand them
cannot consider themselves C programmers and people who abhor them
are likely to never like C.
-- Dan Pop DESY Zeuthen, RZ group Email: Dan.Pop@ifh.de
- Next message: Martin Dickopp: "[OT] Re: Freestanding Environment"
- Previous message: pete: "Re: Arithmetic and C"
- In reply to: Grumble: "Re: Yet another pointer related problem"
- Next in thread: CBFalconer: "Re: Yet another pointer related problem"
- Reply: CBFalconer: "Re: Yet another pointer related problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|