Hi I'm trying to pass in argv into a function that checks the arguments and assigns values for the arguments passed it. When I try to pass in argv, i get the following warning
a2.c:80: warning: passing arg 1 of `checkargs' from incompatible pointer type
what does this warning mean?
Here is my code:
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int checkargs(const char * argv[], int *offset, int *length, int *option, const int argc);
int main(int argc, char * argv[])
{
int *option, *length, *offset;
size_t i;
if(argc < 2 || argc > 4)
{
printf("USAGE: dump [-bcC] [-nlength] [-soffset] [file]");
return 0;
}
checkargs(argv, offset, length, option, argc);
printf("Option: %d \nLength: %d\nOffset: %d", option, length, offset);
}
int checkargs(const char* argv[], int *offset, int *length, int *option, const int argc)
{
size_t i;
for(i = 0; i < argc; i++)
{
if(argv[i][0] == '-')
{
if(argv[i][1] == 'b')
{
*option = 1;
}
if(argv[i][1] == 'c')
{
*option = 2;
}
if(argv[i][1] == 'C')
{
*option = 3;
}
}
if(argv[i][0] == '-')
{
if(argv[i][1] == 'n')
{
if(sscanf(argv[i],"-n %d ", &length) != 1)
{
printf("error getting the length");
exit(1);
}
}
}
if(argv[i][0] == '-')
{
if(argv[i][1] == 's')
{
if(sscanf(argv[i],"-s %d ", &offset) != 1)
{
printf("error getting offset");
exit(2);
}
}
}
}
return 0;
}
Thanks for any help in advance