One function to convert both hex and decimal strings?

A project of mine has an Arduino which runs a serial parser.
You can send commands by sending a line with " ", like “VOLUME 255”.
Now I would like to have the flexibility for the user to either send “VOLUME 255” or “VOLUME 0xFF”

Currently I split the string and use atoi(255) to get the value from the char array (string).
Is there a function which recognizes the 0x automatically or would I have to do an if loop to recognize if the 0x is present? Would be ideal if there was a function that would return the same value for function(255) and function(0xFF).

Thanks

http://www.cplusplus.com/reference/cstdlib/strtol/

Specify base 0 when you call it. Then it will look for the "0x" and do what you asked.

MorganS:
strtol - C++ Reference

Specify base 0 when you call it. Then it will look for the "0x" and do what you asked.

That works! Great, thank you.

would I have to do an if loop

The if STATEMENT does NOT cause looping.