home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!paladin.american.edu!gatech!rutgers!njitgw.njit.edu!hertz.njit.edu!csc5840
- From: csc5840@hertz.njit.edu (Sekhar Chitti)
- Newsgroups: comp.lang.c
- Subject: Could someone answer my question....thanks
- Message-ID: <1993Jan26.000105.10930@njitgw.njit.edu>
- Date: 26 Jan 93 00:01:05 GMT
- Sender: news@njit.edu
- Organization: New Jersey Institute of Technology, Newark, N.J.
- Lines: 45
- Nntp-Posting-Host: hertz.njit.edu
-
- Hi Netters,
-
-
- Following is a C program in which I tried to simulate command
- line arguments (argc, argv). I am not getting the expected
- output which should be the same as when argc, argv are used.
-
-
-
- #include <stdio.h>
-
- main(arg1,arg2)
- int arg1;
- char *arg2[];
- {
- int i;
- for(i=0;i<arg1;i++)
- puts("%d - %s",i,arg2[i]);
- }
-
-
- The following is the output when I tested the program for diff no.
- of arguments. The 'for' loop iterates exactly the number of arguments,
- but when I tried to print the number of args, as u can see from the
- output, I am getting it wrong...
-
- 6:45pm C-> a.out arg2
- %d - %s
- %d - %s
- 6:45pm C-> a.out arg2 arg3
- %d - %s
- %d - %s
- %d - %s
- 6:46pm C-> a.out arg2 arg3 arg4
- %d - %s
- %d - %s
- %d - %s
- %d - %s
- 6:46pm C-> a.out
- %d - %s
-
-
- Could somebody suggest me in this regard ? Thanks in advance.
-
- Sekhar Chitti
-