Re: dumb question, quick solution needed
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