well this program is supposed to convert a binary number to decimal. im new to c and im not very confident in coding C. tried and coded this program but doesnt run properly. and I have no idea what part is wrong here. need some help to complete this program. thanks
binaryToDecimal(char str[]) {
    for(int i = strlen(str)-i; i>=0; i--) {
        if(str[i] == 48 || str[i] == 49) {
            int tmp = pow(2, counter);
            int sum= str[i]*tmp;
            counter++;
            answer += sum;
        } else if(str[i]>49 || str[i]<48) {
            printf("error");
        }
    }
    printf("%d", &answer);
}