strtol converts a string to a long ( as the name tells )

try something like tis

#include <stdio.h>

int main() {
long l = 0;
char buff[] = "0xcf13";
l = strtol(buff,0,0);