void decimal2binary(char *decimal, char *binary) {
//method information goes here
}
This is the main
int main(int argc, char **argv) {
char *data[100];
if (argc != 4) {
printf("invalid number of arguments\n");
return 1;
}
if (strcmp(argv[1] , "-d")) {
if (strcmp(argv[3] , "-b")) {
decimal2binary(temp, data);
}
}
}
Now I get this error
warning: passing argument 2 of ‘decimal2binary’ from incompatible pointer type [enabled by default]
note: expected ‘char *’ but argument is of type ‘char **’
So it says they are incompatible types but I have to use argv to get the data (that how I was asked) is there any other way?
Change the declaration of
datato simply:You don’t need an array of pointers to type
char, which is what you’ve declared as your code stands right now. You simply want a byte array. I believe your confusion stems from the fact that while arrays are not pointers, they do decay into pointers to the first element of the array when passed as a function argument. So by simply sayingdecimal2binary(temp, data);, you are passing a pointer to the first element ofdata, and in this case you need that to be a pointer to achar, not achar*.