[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: /*MerryChristmas.c*/
- From: Conrad Meyer <konrad tylerc org>
- To: paul all-the-johnsons co uk, Development discussions related to Fedora <fedora-devel-list redhat com>
- Cc:
- Subject: Re: /*MerryChristmas.c*/
- Date: Wed, 24 Dec 2008 16:24:42 -0800
On Wednesday 24 December 2008 03:53:30 pm Paul wrote:
> Hi,
>
> > /*MerryChristmas.c*/
> > void main (int argc, char* argv[])
>
> main has never and will never return anything other than an int. It's in
> the standard!!!!
>
> > {
> > printf("\n Merry Christmas! \n");
> > if (strcmp(argv[1],"girl") == 0) /*general idea*/
> > printf("Kisses! \n");
> > else
> > printf("Hugs! \n");
> > }
>
> Ouch! What happens though if argv[1] is "Girl" or "gIrl" (you get the
> idea). Surely something like
>
> if (strcmp(tolower(argv[1])),"girl)
More like:
if (!strcasecmp(argv[1], "girl"))
> would make more sense and catch the problems. However, we don't take
> into account here if argv[1] is null, so a catch is required..
This is C, no catches. Check argc >= 2.
> Oh dear. I need sleep.
>
> MERRY CHRISTMAS FOLKS!!!!!
>
> TTFN
>
> Paul
Yup :).
--
Conrad Meyer <konrad tylerc org>
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]