number conversion problem in arduino

hi all
i want to convert 2 or 4 byte hex number to decimal number.
like 0xff to 255 or 0xffff to 65,535.
how can i do it in arduino?
please help or send the code.

i am new in arduino

i got this routine from internet but i dont know that how to use it as function?

//////////////////////////////////////////////

unsigned int hexToDec(String hexString) {

unsigned int decValue = 0;
int nextInt;

for (int i = 0; i < hexString.length(); i++) {

nextInt = int(hexString.charAt(i));
if (nextInt >= 48 && nextInt <= 57) nextInt = map(nextInt, 48, 57, 0, 9);
if (nextInt >= 65 && nextInt <= 70) nextInt = map(nextInt, 65, 70, 10, 15);
if (nextInt >= 97 && nextInt <= 102) nextInt = map(nextInt, 97, 102, 10, 15);
nextInt = constrain(nextInt, 0, 15);

decValue = (decValue * 16) + nextInt;
}

return decValue;
}

I am sorry to sat that the code written in the bottom of above, is an .ino file.
How can i include this file in to my file?

For the "String" class:-

String hexString = "0xff";
unsigned int iVal = (unsigned int)strtol(hexString.c_str(), NULL, 16);

or for (the better) C strings:-

char hexString[] = "0xff";
unsigned int iVal = (unsigned int)strtol(hexString, NULL, 16);

(These are OK for positive values up to 0xffff, (65535).

Edit: And regarding posting code.
In the post or "Reply" window, if you first paste your code into the window then select it, pressing the </> button will place code tags around the code.

Alternatively, paste your code into the post, then type these (code tags) immediately before and after the code:-[code]
// Your code here

[/code]