Reputation: 1074
Here I wrote a little app which is able to read command line arguments
int main (int argc, const char * argv[])
{
int c;
while ((c = getopt (argc, argv, "Il:o:vh?")) != -1)
{
switch(c)
{
case 'I':
printf("I");
break;
}
}
return 0;
}
The problem is that when I try to compile it the compiler prints
warning: passing argument 2 of ‘getopt’ from incompatible pointer type
and program crash. What I miss ?
Upvotes: 2
Views: 544
Reputation: 15184
int main (int argc, const char * argv[])
should be
//no const
int main (int argc, char * argv[])
Upvotes: 3