User-defined functions

It errors.
Error 1 error LNK2019: unresolved external symbol "char __cdecl price(char,int)" (?price@@YADDH@Z) referenced in function _main c:\Users\sony vaio\documents\visual studio 2013\Projects\Project4\Project4\Source.obj Project4

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
 #include<iostream>
#include<string.h>
using namespace std;

char sprice[10];
int slength, I;
char price(char, int);

int main()
{
	cout << "\nEnter price: ";
	cin.getline(sprice, 10);
	slength = strlen(sprice);
	price(sprice[10], slength);
	
    system("pause>0");
	return 0;
}

char price(char sprice[10], int slength)
{
	for (I = 0; I < slength; I++)
	{
		switch (sprice[I]){
		case '0': cout << "X"; break;
		case '1':cout << "C"; break;
		case '2':cout << "O"; break;
		case '3':cout << "M"; break;
		case '4':cout << "P"; break;
		case '5':cout << "U"; break;
		case '6':cout << "T"; break;
		case '7':cout << "E"; break;
		case '8':cout << "R"; break;
		case '9':cout << "S"; break;
		case '.':cout << "."; break;
		}
	}
	return sprice[I];
}


What is this program supposed to do?
Sample Output:

Enter price: 432.01
PMO.XC
Fix your forward declaration to char price(char sprice[10], int slength).
it still errors though
should call

price(sprice, slength); instead after defining the declaration to be

char price(char[], int);
Topic archived. No new replies allowed.