warning: format ‘%p’ expects argument of type ‘void *’, but argument 3 has type ‘char **’

前端 未结 3 1146
孤街浪徒
孤街浪徒 2021-01-18 04:59

I\'m trying to print out the value of argv at this point in my code, but when I try to compile it, I get warning: format ‘%p’ expects argument of type ‘vo

3条回答
  •  心在旅途
    2021-01-18 05:19

    In order to print argv and it's address you need to do

    int main(int argc, char* argv[])
    {
        int i;
        printf("address of argv = %p\n", (void *)argv);
        for (i = 0; i < argc; ++i)
        {
            printf("%s\n", argv[i]);
        }
        return 0;
    }
    

提交回复
热议问题