n179911
n179911

Reputation: 20301

How to resolve initialization from incompatible pointer type

I have the following c code:

int argv = 2;
char **argv = {"test arg 1",
          "test arg 2"};

When I compile it, I get teh following warning:

warning: initialization from incompatible pointer type [enabled by default]

Can you please tell me what's wrong for my initialization?

Thank you.

Upvotes: 0

Views: 1323

Answers (1)

ouah
ouah

Reputation: 145839

char ** is a pointer type not an array type.

Use an array type:

char *argv[] = {"test arg 1", "test arg 2"};

Upvotes: 3

Related Questions