How to convert hexdecimal string to long int in C

1 Answer

0 votes
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) 
{
	long int n;
	char s[] = "FF";
		
	n = strtol(s, NULL, 16);
	printf ("hexadecimal number %lX = %ld\n",n, n);
	
    return 0;
}
   
 
/*
run:
 
hexadecimal number FF = 255

*/

 



answered Mar 4, 2016 by avibootz

Related questions

1 answer 187 views
1 answer 231 views
1 answer 162 views
162 views asked Aug 6, 2019 by avibootz
1 answer 192 views
192 views asked Aug 5, 2019 by avibootz
1 answer 125 views
1 answer 180 views
...