Defining own main functions arguments argc and argv

前端 未结 6 2350
野性不改
野性不改 2020-12-09 15:16

i want to create an object of type QApplication which needs the main functions arguments argc and argv as an input:

QApplication app(argc, argv);
         


        
6条回答
  •  离开以前
    2020-12-09 15:57

    Quick and dirty, but working for QApplication:

    char *argv[] = {"program name", "arg1", "arg2", NULL};
    int argc = sizeof(argv) / sizeof(char*) - 1;
    

    For a more complete and C standard conforming solution see D.Shawley's answer.

    Why your solution doesn't work is simple:

    array[i][j] results in a i*j matrix. But what you actually want is an array with pointers to strings in it.

提交回复
热议问题