I have made this code for a homework problem but I get warning and I don't understand why. And when I open the program it doesn't work.
This is the code:
#include <stdio.h>
#include <math.h>
int binarytodec(int array[]) {
int i, result=0, n = sizeof(array)/sizeof(array[0]);
for( i=0; i<n; i++ ) {
if(array[i]==1) {
result +=pow(2,i);
} else if(array[i]==0) {
result +=0;
}
else break;
}
return result;
}
int main() {
int b[] = {1,1,1,0,0,1,0,0,12};
binarytodec(b);
return 0;
}
The warning is:
warning: sizeof on array function parameter will return size of 'int *' instead of 'int []' [-Wsizeof-array-argument] int i, result=0, n = sizeof(array)/sizeof(array[0]);
What is the problem?
Thank you