This is a discussion on How do I access command-line arguments? within the C and C++ Programming forums, part of the Software Development category; Hi, Can anyone tell me general ways to access command-line arguments? plz give an example. Thanks, Prasath.K...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, Can anyone tell me general ways to access command-line arguments? plz give an example. Thanks, Prasath.K Last edited by Booom : 08-18-2007 at 01:23 AM. |
| Sponsored Links |
| |||
| hey, Command line arguments are space seperated character strings. In our contest, you enter these strings in a special window in the client. These arguments are given to your program in specially defined character arrays. In C/C++ the number of arguments is also passed into your program in a specially declared integer. In java, this can be obtained by getting the length of the argument array, as shown below. In the code skeletons (provided in the client), you can access the command line arguments in the following ways.: Example of using command line args with C++ #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i,j; for (i = 1; i < argc; i++) printf("%s ",argv[i]); printf("\n"); printf("The first argument as a number is: %d\n", atoi(argv[1]) ); return 0; } Java
__________________ Venkat knowledge is Power |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can I execute a PHP script using command line? | sundarraja | PHP Programming | 0 | 01-28-2008 02:53 AM |
| Using PHP from Command Line | Sabari | PHP Programming | 4 | 12-18-2007 06:42 AM |
| How do I read command-line arguments with Perl? | leoraja8 | Perl | 3 | 11-26-2007 06:43 AM |
| How do I run a php script from the command line | itbarota | PHP Programming | 1 | 09-11-2007 03:06 AM |
| How do I read command-line arguments with Perl? | sivaramakrishnan | Perl | 1 | 07-23-2007 04:50 AM |