• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: dumb question, quick solution needed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dumb question, quick solution needed


  • Subject: Re: dumb question, quick solution needed
  • From: Justin Walker <email@hidden>
  • Date: Thu, 17 Feb 2005 18:40:55 -0800


On Feb 17, 2005, at 18:29, D.Walsh wrote:

Sometimes you forget the simple things, and while brain-freeze has set in this has me stumped, I thought I could define argv as a long but this doesn't work.

'theNumber' has to be a long as required by the remainder of the program (not present) but it appears to be a string, anyone know what I'm forgetting to do hear?

The (command-line) arguments to a program are strings. Period. You don't get to choose. If you want the values to be integers, your "main" program (or something it calls) has to translate.


The issue is that the shell (which reads your input, sets up the arguments, and calls your program) has no idea what to do with "123": is it a number? A string? A filename? A secret code (shame on you for passing a password on the command line)?

You can use the C library to translate (see, e.g., 'man strtol').

Regards,

Justin

--
Justin C. Walker, Curmudgeon-At-Large  *
Institute for General Semantics        |   When LuteFisk is outlawed
                                       |   Only outlaws will have
                                       |       LuteFisk
*--------------------------------------*-------------------------------*

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Distributed builds on headless XServe (From: Alastair Houghton <email@hidden>)
 >dumb question, quick solution needed (From: "D.Walsh" <email@hidden>)

  • Prev by Date: dumb question, quick solution needed
  • Next by Date: .dylib project
  • Previous by thread: dumb question, quick solution needed
  • Next by thread: Setting user defaults for an app launch?
  • Index(es):
    • Date
    • Thread