![]() |
|
|
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 |
| command line args 2 | skooly5 | UNIX for Dummies Questions & Answers | 2 | 04-06-2008 10:36 PM |
| command line args | skooly5 | UNIX for Dummies Questions & Answers | 2 | 04-06-2008 08:46 PM |
| alias with args how to ... | umen | UNIX for Dummies Questions & Answers | 4 | 12-28-2005 07:47 AM |
| required command line args | yoi2hot4ya | UNIX for Dummies Questions & Answers | 6 | 06-02-2005 07:50 PM |
| Args to Array | Shaz | Shell Programming and Scripting | 2 | 06-30-2003 05:11 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Command line args
My program usage takes the form for example;
$ theApp 2 "one or more words" i.e. 3 command line arguments; application name, an integer, some text My code includes the following 4 lines: int anInteger; char words[80]; sscanf(argv[1], "%d", &anInteger); sscanf(argv[2], "%s", &message); Based on th example execution shown above this code results in th following assignments: anInterger = 2 /* correct and as I thought*/ message = one /* not as I thought or intended*/ I thought when I printed out the value of message I would get: one or more words but instead I get: one I have done a test and the use of the " " marks seems to make "one or more words" be seen as a single argument. If I don't use the " " marks it sees every word as another argument. So even though the program sees "one or more words" as a single argument, sscanf is not reading it properly. How can I overcome this problem? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|