RE: Using argv[1] in C program

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: David Koopman
Date:  
To: plug-discuss
Subject: RE: Using argv[1] in C program
>
> I think what you're looking for is atoi(char*). (see `man atoi` for
> other options).
>
> The parameter to usleep needs to be an unsigned long.
>
> Bart



Thank you. It works now. I had figured out how to take command line
arguments, but needed the atoi() function to finish this off.

shell> vi usleep.c

int main(int argc, char** argv) {
  if ( argc > 1 )
    usleep(atoi(argv[1]));
}


shell> make usleep
shell> cp usleep /usr/local/bin/
shell> usleep 250000 # sleep for a quarter second

Now my system has usleep on it!! Awesome, that was fun.


---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss