How do I convert a string representation of a hex to its hex value in c? -


if have

char input[50] = "xffff"; int a; 

how can store numerical value of input in a? language c.

one way might be:

if (sscanf(input, "x%x", &a) == 0) {     /* matching failed */ } 

if input uses real hex specifier (like "0xffff") can use %i:

if (sscanf(input, "%i", &a) == 0) {     /* matching failed */ } 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -