![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why does the 'ps' command with -u option not working? | ElCaito | SUN Solaris | 4 | 02-26-2006 07:14 PM |
| Usage of optarg | sveera | Shell Programming and Scripting | 5 | 07-19-2005 06:21 PM |
| option for ls command | eloquent99 | UNIX for Dummies Questions & Answers | 1 | 02-07-2003 06:27 PM |
| tar command with compress option... | tomapam | UNIX for Dummies Questions & Answers | 3 | 10-11-2002 12:56 PM |
| -c option in ping command | Deepa | Shell Programming and Scripting | 3 | 05-31-2002 06:05 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi
I'm learning how to add in programm another option by command line. For example in the "my_prog" i want to add a " -k " option and then write a number. I mean: Code:
my_prog -k 50 I'm reading about getopt_long and optarg, and what i have done in the code is to add k in the getop_long as: Code:
c = getopt_long (*pargc, argv, "B:T:z:k:gpdht", long_options, &option_index) Code:
case 'k':
number_i_want = optarg;
routine_that_use_number_i_want(number_i_want);
break;
Anyone can help? Thanks D. -----Post Update----- Sorry I got it. All i have to do is translate the char to int with the atoi() function. Code:
number_i_want=atoi(optarg) D. Last edited by otheus; 06-18-2009 at 08:42 AM.. |
| Sponsored Links | ||
|
|
| Bits Awarded / Charged to Dedalus for this Post | |||
| Date | User | Comment | Amount |
| 06-18-2009 | otheus | For solving own problem and posting it on the forum! | 1,000 |
![]() |
| Bookmarks |
| Tags |
| command-line, getopt_long, optarg |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|