How to find the length of argv[] in C

后端 未结 8 2111
青春惊慌失措
青春惊慌失措 2020-12-15 06:41
#include 
#include 
#include 

int main(int argc, char *argv[]){
    int fir; //badly named loop variable
    char *in         


        
8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-15 07:13

    Not sure why no one has suggested changing strlen to refer to a specific entry in the array of pointers to char?

     strlen(argv[0])     // also, 1, 2, up to (argc - 1)
    

    Also, http://www.cdecl.org/ helps in confirming that the char *argv[] statement is: declare argv as array of pointer to char

提交回复
热议问题