My assignment is:
(Exercise 11-4 from Practical C Programming, Steve Oualline)
"Write a program that counts the number of bits set in an integer. For example,
the number 5 (decimal), which is 0000000000000101 (binary), has two bits set."
More specifically, write a function, countBits() that takes an int as an
argument and returns an integer count of the number of set bits. Then write a
main function that reads an integer from the command line and outputs the
return value of countBits() to the screen.
I've rewritten the program from scratch and finally limited the number of small errors (mismatched variables, undefined terms, etc) but now there is some huge system failure that pops up every time I try to compile the program. What is wrong????
int countBits(int a, int b)
c = 0;
for (d=0; d<b; d++)
if(a[d] == 1)
int main(int argc, char *argv)
d = 0;
printf("Enter the integer whose count bit is to be found:\n");
fgets(line, sizeof(line), stdin);
sscanf(argv, "%d", &g);
i = g - (f*2);
fil[d] = i;
g = f;
a = countBits(fil, d);
printf("The set bits are %d\n", a);