I'm trying to pass by value an array, or rather a pointer to an array to the function BinaryToHex. However I consistently get the error "conflicting types for function BinaryToHex".
Here is the relevant portion of the program.
char *ConvertCodeToHex(char code[16])
{
char nibble[4];
char hexvalue[4];
int i;int j,k = 0;
for(i=0; code[i] != '\0'; i++)
{
if((i+5)%4 == 0)
{
nibble[j] = '\0';
j = 0;
hexvalue[k] = BinaryToHex(nibble);
k++;
}
nibble[j] = code[i];
j++;
}
strncpy(finalhex, hexvalue, 4); //finalhex is a global character array
return finalhex;
}
char BinaryToHex(char b[4]) //The error is caught in this line of code.
{
int temp = 0,i; char buffer;
for(i=4; i >= 0; i-- )
{
int k = b[i]-='0';
temp += k*pow(2,i);
}
//Converting decimal to hex.
if (temp == 10)
return 'A';
else if (temp == 11)
return 'B';
else if (temp == 12)
return 'C';
else if (temp == 13)
return 'D';
else if (temp == 14)
return 'E';
else if (temp == 15)
return 'F';
else
return (char)(((int)'0')+ temp);
}