Week3 Lecture: A student asked a question of my mind how do computer know about the argc ? I really don't understand how is this argc working In case we printed "zymla" we gave argv[1] as our first command was hello-4 and second was zymla Where is the role of "argc" ?

  • 1
    If you're satisfied with Chris' answer, please click on the check next to it to accept it and to remove it from the unanswered questions pool. Let's keep up on forum maintenance. ;-)
    – Cliff B
    Commented Aug 6, 2015 at 20:29

1 Answer 1


If I understand your question correctly, and it's "what is the role of argc" the answer is that we need it to know how many arguments were passed to main from the command line. So if the command was ./hello-4 Zamyla we have argc == 2 and argv[0] == "./hello-4" and argv[1] == "Zamyla". Without argc you wouldn't know the length of argv.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .