Octal To Decimal

This algorithm converts octal numbers to decimal numbers.



									/*****Please include following header files*****/
// string
/***********************************************/

/*****Please use following namespaces*****/
// std
/*****************************************/

static int OctalToDecimal(string octal) {
	int octLength = octal.length();
	double dec = 0;

	for (int i = 0; i < octLength; ++i)
	{
		dec += (octal[i] - 48) * pow(8, ((octLength - i) - 1));
	}

	return (int)dec;
}
								


Example

									string data = "2430357";
int value = OctalToDecimal(data);
								


Output

									667887