Unresolved Externals?
So I've written out a program that is supposed to convert hexadecimal numbers to normal numerals. however, i keep getting this error:
Error 6 error LNK2019: unresolved external symbol "double __cdecl cNum(char * const,int)" (?cNum@@YANQADH@Z) referenced in function _main c:\Users\Username\documents\visual studio 2012\Projects\HexAdder\Source.obj HexAdder
Anyone know what this means???
Here's my code for reference:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#include <iostream>
#include <cmath>
using namespace std;
void fill_array(char a[], int size);
double cNum(char a[], int size);
const int SIZE = 10;
int main()
{
char hex1[SIZE], hex2[SIZE];
int number_used;
double num1, num2;
num1 = cNum(hex1, SIZE);
fill_array(hex1, SIZE);
for (int i = 0; i <= (SIZE - 1); i++)
cout << hex1[i];
cout << endl << num1;
system("pause");
return 0;
}
void fill_array(char a[], int size)
{
cout << "Enter a number in hexadecimal format up to 10 digits long\n"
<< "Mark the end with an asterisk(*)\n";
char next;
int i = (size - 1);
cin >> next;
while (i >= 0)
{
if (next != '*')
{
a[i] = next;
i--;
cin >> next;
}
else
{
a[i] = '0';
i--;
}
}
}
double cNum(const char hex[], const int size)
{
double sum;
char a[SIZE];
for (int i = 0; i < size; i++)
{
switch (hex[i])
{
case '0':
a[i] = 1;
case '1':
a[i] = 2;
case '2':
a[i] = 3;
case '3':
a[i] = 4;
case '4':
a[i] = 5;
case '5':
a[i] = 6;
case '6':
a[i] = 7;
case '7':
a[i] = 8;
case '8':
a[i] = 9;
case '9':
a[i] = 10;
case 'a':
a[i] = 11;
case 'b':
a[i] = 12;
case 'c':
a[i] = 13;
case 'd':
a[i] = 14;
case 'e':
a[i] = 15;
case 'f':
a[i] = 16;
}
a[i] = pow(16, i) * hex[i];
sum += a[i];
}
return sum;
}
|
Also, that switch is huge and unruly. Anyone have any other suggestions to converting?
Your prototype: double cNum(char a[], int size);
Your definition: double cNum(const char hex[], const int size)
They need to be the same.
Topic archived. No new replies allowed.