"digitsIn(int)", referenced from:
binaryToDecimal(int)in Binary Conversion.o
binaryToDecimal(int)in Binary Conversion.o
binaryToDecimal(int)in Binary Conversion.o
binaryToDecimal(int)in Binary Conversion.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
digitsIn (int) is a function I wrote in another application (given an integer, it finds the number of digits in that integer) . I've included it by including the header file from that application
1 2 3 4 5 6 7 8
// header.h from this project:
#include "[path to other project]/header.h"
#include <cmath>
#include <iostream>
usingnamespace std ;
int decimalToBinary (intconst decimalNum) ;
int binaryToDecimal (intconst binaryNum) ;
1 2 3 4 5
// header.h from other project:
#include <iostream>
usingnamespace std ;
int digitsIn (intconst num) ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// from main.cpp (this project)
int binaryToDecimal (intconst binaryNum) {
int h = binaryNum ;
int binaryNum_array [digitsIn (binaryNum) ] ;
int decimalNum ;
for (int i = 0 ; i <= digitsIn (binaryNum) ; i ++ ) {
binaryNum_array [i] = h % 10 ;
h /= 10 ;
}
for (int i = digitsIn (binaryNum) ; i >= 0 ; i -- ) {
decimalNum += pow (d2, digitsIn (binaryNum) - i) ;
}
return decimalNum ;
}