Octal To Decimal

This algorithm converts octal numbers to decimal numbers.



									/*****Please include following header files*****/
// math.h
/***********************************************/

int OctalToDecimal(char* octal) {
	int octLength = strlen(octal);
	double dec = 0;

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

	return (int)dec;
}
								


Example

									char* data = "2430357";
int value = OctalToDecimal(data);
								


Output

									667887