I want to enter some command line arguments at run time. Like
./program abc def ghi
argc
would be 4 in this case. No problem in this. But if I do
./program abc def *
or even
./program * abc def
the variable argc
gives me a value far larger than 4.
On printing the entire argv
array (leaving aside the 0th argument; ./program
) as strings, I am given a list where the first two elements are abc
and def
and the others are all file names of the files contained in the working directory.
I am trying to learn C from K&R. I was trying to make an RPN calculator where we can give expressions like ./program 2 4 *
.
What is the reason for this? Or am I wrong somewhere?