In any shell command, I think shell replaces * with all the files in the current directory.
As an example try giving man *. So in you program, the ./hello * , is interpreted as ./hello and other filenames in your directory. Hence the result. -usha hegde _____ From: [email protected] [mailto:[email protected]] On Behalf Of Sudipta Deb Sent: Thursday, July 09, 2009 1:06 AM To: [email protected] Subject: [c-prog] Command Line Argument Hi, I have a very simple C program which will run in UNIX. When i am passing * as the command line argument, i am gettig the below output. Program: #include <stdio.h> #include "mylibrary.h" int **environ; int main(int argc,char *argv[]) { int i; printf("\nHello World"); printf("\nNumber of arguments: %d\n",argc); for(i=0;i<argc;i++) { printf("\nArgument # %d is: %s\n",i,argv[i]); } return 1; } Compile: cc hello.c -o hello Run: ../hello * Output: Hello World Number of arguments: 5 Argument # 0 is: ./hello Argument # 1 is: hello Argument # 2 is: hello.c Argument # 3 is: mylibrary.h Can somebody please explain me what is the exact reason of this output. Thanks Sudipta. [Non-text portions of this message have been removed] __________ Information from ESET NOD32 Antivirus, version of virus signature database 4188 (20090625) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com [Non-text portions of this message have been removed]
