
September 10th, 2002, 05:12 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Hehe, I was about to code a similar function just now for my own project, when suddenly I remembered a function from a long time ago.  It's called sscanf(). It works the same as scanf() except that it uses a string for its first argument and a format string for the second argument (sort of like sprintf()). If you want, here's some code I tried out:
Code:
#include <stdio.h>
int main() {
char *foo = "F00";
int x;
sscanf(foo, "%X", &x);
printf("Hex %s is dec %d", foo, x);
return 0;
}
Hope this helps!
|