Command line arguments in C

前端 未结 6 1718
时光说笑
时光说笑 2020-12-21 01:35

I have this program execute with the values 10,20,30 given at command line.

int main(int argc , char **argv)
 { 
  printf(\"\\n Printing the arguments of a         


        
6条回答
  •  庸人自扰
    2020-12-21 02:03

    argc will have number of elements which can be accessed from argv[0] to argv[argc-1]. So modify your condition accordingly viz print from argv[argc-1].

    Here is a command line arguments tutorial link as there are many things which you may have missed when reading it. Hence you are not able to understand the reason for that output.

    Numbering for indexes is usually from 0, because of many reasons. Please check this question which will help you understand why its zero based. https://stackoverflow.com/questions/393462?tab=votes&page=1#tab-top

提交回复
热议问题