If you just want to assign a hex value to an int or a long, then prefix it with 0x, for example:
long lFoo;
lFoo = 0x5FF;
If, as your question implies, you want to convert a string (null terminated character array) to a value, interpreting the characters within it as hex digits, you can use either of strtol() or sscanf()...your compiler and libraries may provide other possibilities, but it is certain that sscanf() will be there. For example:
char* pStr = "5FF"; // Text string
char* pAfter;
long lFoo = strtol( pStr, &pAfter, 16 ); // Converts string to long using base 16 (hex), returns value
long lFoo2;
sscanf( pStr, "%lx", &lFoo2 ); // Stores converted value in lFoo2