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&lt;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.

The shell is expanding the asterisk to the files in the current directory. Similar expansion happens with ?, shell variables, and character classes '[..]'. Standard behavior for all proper UNIX shells.

Use '*' instead if you want to pass a literal asterisk.

OK Thanks a lot. Now i understood what is the reason of the output.

---------- Post updated at 04:19 AM ---------- Previous update was at 01:00 AM ----------

Just want to share one information this technique is known as Glob Programming. You can get the information in wikipedia. Here comes the link:
http://en.wikipedia.org/wiki/Glob_\(programming\)