Help with string to int

Any idea for the code for my getDigit function? I have to add on one digit at a time while in my loop. Dont know how to pick off one digit at a time. Is the function prototype correct so far?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 int convertToBase10 (string number, int base)
{
	int ans = 0;
	int x = base;
	int pos = 0;

	for (unsigned int k = 0; k < number.length(); k++)
	{
		ans = (ans * x) + getDigit(number,pos++);
	}

	return ans;
}

int getDigit (string number, int position)
{
	

	return ;
}
number[k] would give you the character in the position `k'


By the way, `k' and `pos' have the same value, ¿do you need both variables?
Topic archived. No new replies allowed.