strtol

I have a number that is between 1 and 3 digits long inclusive and wanted to convert it to a long int ( in C)


1
2
3
4
5
	
char num[64] = "493";
char *pEnd;
long int a;
a = strtol(line,&pEnd,10);

Above code works but what does number 10 represent?
why replacing the 10 with a 3 (should be maximum amt of digits) doesn't give the correct long int?
also, what does pEnd do?
Last edited on
It represents the base of the number being copied to a.
ie: if you want a to have the hexadecimal(base 16) of 493(value of num[64]) in a, then replace the 10 with 16
oh, so thats why if change it to 3 it only allowed numbers [0,1,2] but making it a base 16 would be same as base 10, but just with ABCDEF capabilities
Topic archived. No new replies allowed.