Hi guys, i am looking for a little assistance. What i am trying to write is a function that will take a 7 bit character then read its binary value. It will determine if the the amount of 1's are even or odd. if odd, it will make it even by XOR 0x80.
My code works if i have a regular char (and i get rid of all the pointer references) but in this method i am passing it via a pointer. Could someone please take a look and provide some feedback or possible solutions. When i compile i am getting:
orig.c: In function `makeEven':
orig.c:165: warning: `return' with a value, in function returning void
Here is my function:
Code:
void makeEven(unsigned char* somebyte) {
unsigned char temp;
unsigned char x;
int count1 = 0;
x = *somebyte;
temp = *somebyte;
//counts the 1's
while (temp > 0) {
if (temp & 1 == 1)
count1++;
temp >>= 1;
}
printf("\nThe Count is: %d\n", count1);
if (count1 % 2 == 0){
printf("\nIt is Even\n");
}
else {
x = x^0x80;
printf("\nIt is odd\n");
printf("\n%x\n",x);
}
return x;
}