Ili mozes da koristis vec gotovu funkciju strtoul (definisana u header-u stdlib.h):
Code:
unsigned long strtoul(
const char *nptr,
char **endptr,
int base
);
Parameters:
nptr Null-terminated string to convert.
endptr Pointer to character that stops scan.
base Number base to use.
Return Value
strtoul returns the converted value, if any, or ULONG_MAX on overflow.
strtoul returns 0 if no conversion can be performed.
Errno is set to ERANGE if overflow or underflow occurs.
Mali primer:
Code:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main()
{
printf("(hex) FF = (dec) %d", strtol("FF", NULL, 16));
printf("press any key...");
getch();
return 0;
}
[Ovu poruku je menjao DarkMan dana 27.10.2005. u 23:52 GMT+1]