The code.The 3rd parameter won't pass from the compiler.Why?
I have the function in other file but i do not think this is a problem,right?
Code:
int input(int n ,const int argc, const char **argv)
{
if(argc != 1 && strcmp(argv[1] , "-" ) ==0 ) {
n = atoi(argv[2]);
if( n <= 0 )/*atoi may return 0 for invalid input,or the input may be zero*/
{
printf("Sorry , invalid input or input is non-positive\n");
printf("Input format is ./<executableName> - <n> .Notce that \"-\" and");
printf(" <n> must be seperated by a whitespace\n");
printf("Input will be set to ten.\n");
n = 10;
}
}
return n;
}
int main(int argc, char *argv[])
{
int n = 10;
n = input( n , argc , argv);
printf("%d\n",n);
return 0;
}
the error
Code:
Macintosh-c8bcc88e5669-9:hw6 usi$ gcc -Wall tail.c line.c -o t
tail.c: In function ‘main’:
tail.c:10: warning: passing argument 3 of ‘input’ from incompatible pointer type
Macintosh-c8bcc88e5669-9:hw6 usi$
Also googled and saw this
c - Can't pass argv to function - Stack Overflow
but i think i do the same
What i am missing here?