/*MerryChristmas.c*/ void main (int argc, char* argv[]) { printf("\n Merry Christmas! \n"); if (strcmp(argv[1],"girl") == 0) /*general idea*/ printf("Kisses! \n"); else printf("Hugs! \n"); }
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)
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..
Oh dear. I need sleep.
MERRY CHRISTMAS FOLKS!!!!!
TTFN
Paul
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 escreveu:
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 :).
Nerds hehehe!!
Best regards!
haha Merry Xmas. =)
2008/12/25 Rodrigo Padula de Oliveira rodrigopadula@projetofedora.org
Conrad Meyer escreveu:
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 :).
Nerds hehehe!!
Best regards!
--
Rodrigo Padula de Oliveira M.Sc. Student - COPPE/UFRJ Fedora Community Manager - Latin America http://www.proyectofedora.org
-- fedora-devel-list mailing list fedora-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-devel-list
On Wed, Dec 24, 2008 at 3:11 PM, Rodrigo Padula de Oliveira rodrigopadula@projetofedora.org wrote:
/*MerryChristmas.c*/ void main (int argc, char* argv[]) { printf("\n Merry Christmas! \n"); if (strcmp(argv[1],"girl") == 0) /*general idea*/ printf("Kisses! \n"); else printf("Hugs! \n"); }
#i!/bin/env python import sys print 'Kisses!' if len(sys.argv) == 2 and sys.argv[1].lower() == 'girl' else 'Hugs!'
Arthur Pemberton wrote:
On Wed, Dec 24, 2008 at 3:11 PM, Rodrigo Padula de Oliveira rodrigopadula@projetofedora.org wrote:
/*MerryChristmas.c*/ void main (int argc, char* argv[]) { printf("\n Merry Christmas! \n"); if (strcmp(argv[1],"girl") == 0) /*general idea*/ printf("Kisses! \n"); else printf("Hugs! \n"); }
#i!/bin/env python import sys print 'Kisses!' if len(sys.argv) == 2 and sys.argv[1].lower() == 'girl' else 'Hugs!'
#! /usr/bin/env ruby
class Object def response "Hugs!" end end
class String def response return "Kisses!" if self.downcase == "girl" super end end
puts "Merry Christmas!\n#{ARGV[0].response}"
On Sun, 2008-12-28 at 21:50 -0500, Casey Dahlin wrote:
Arthur Pemberton wrote:
On Wed, Dec 24, 2008 at 3:11 PM, Rodrigo Padula de Oliveira rodrigopadula@projetofedora.org wrote:
/*MerryChristmas.c*/ void main (int argc, char* argv[]) { printf("\n Merry Christmas! \n"); if (strcmp(argv[1],"girl") == 0) /*general idea*/ printf("Kisses! \n"); else printf("Hugs! \n"); }
#i!/bin/env python import sys print 'Kisses!' if len(sys.argv) == 2 and sys.argv[1].lower() == 'girl' else 'Hugs!'
#! /usr/bin/env ruby
class Object def response "Hugs!" end end
class String def response return "Kisses!" if self.downcase == "girl" super end end
puts "Merry Christmas!\n#{ARGV[0].response}"
#!/usr/bin/sbcl --script (princ #\newline) (princ "Merry Christmas!") (princ #\newline)
(let ((argv sb-ext:*posix-argv*)) (if (> (length argv) 1) (let ((type (string-downcase (cadr argv)))) (if (equal type "girl") (princ "Kisses!") (princ "Hugs!")))))
(princ #\newline)
Gérard Milmeister пишет:
On Sun, 2008-12-28 at 21:50 -0500, Casey Dahlin wrote:
Arthur Pemberton wrote:
On Wed, Dec 24, 2008 at 3:11 PM, Rodrigo Padula de Oliveira rodrigopadula@projetofedora.org wrote:
/*MerryChristmas.c*/ void main (int argc, char* argv[]) { printf("\n Merry Christmas! \n"); if (strcmp(argv[1],"girl") == 0) /*general idea*/ printf("Kisses! \n"); else printf("Hugs! \n"); }
#i!/bin/env python import sys print 'Kisses!' if len(sys.argv) == 2 and sys.argv[1].lower() == 'girl' else 'Hugs!'
#! /usr/bin/env ruby
class Object def response "Hugs!" end end
class String def response return "Kisses!" if self.downcase == "girl" super end end
puts "Merry Christmas!\n#{ARGV[0].response}"
#!/usr/bin/sbcl --script (princ #\newline) (princ "Merry Christmas!") (princ #\newline)
(let ((argv sb-ext:*posix-argv*)) (if (> (length argv) 1) (let ((type (string-downcase (cadr argv)))) (if (equal type "girl") (princ "Kisses!") (princ "Hugs!")))))
(princ #\newline)
#!/usr/bin/php <? if (strtolower(@$argv[1]) == 'girl') /*general idea*/ echo "Kisses! \n"; else echo "Hugs! \n"; ?>