driedupsharpie driedupsharpie - 4 months ago 8
Bash Question

Finding the Number of Elements in an Array of Command Line Arguments?

I'm working off of a Linux command line with g++ and the code will be executed like so:

./mycode arg1 arg2 arg3 ...


This works fine as I am using the array
argv[]
and the following for main:

int main (int argc, char *argv[])


However there is a part of my program where I need to know the number of command line arguments given.
sizeof()
is failing me here. Any ideas of how this could be accomplished?

Answer

This is what the argc stands for