From: hackbard Date: Sat, 4 Jan 2003 14:42:25 +0000 (+0000) Subject: added hex to interger calculator :) X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=f9fdaf4ff30b80f060a3662cd683dcaf7ce74dce;p=my-code%2Fbeginners.git added hex to interger calculator :) --- diff --git a/h2i-calc.c b/h2i-calc.c new file mode 100644 index 0000000..5042af6 --- /dev/null +++ b/h2i-calc.c @@ -0,0 +1,11 @@ +#include +#include + +int main(int argc,char *argv[]) { + char hex_char[10]; + sprintf(hex_char,"0x%s",argv[1]); + printf("%s (dec) -> %x (hex)\n",argv[1],atoi(argv[1])); + printf("%s (hex) -> %ld (dec)\n",argv[1],strtol(hex_char,NULL,0)); + return 1; +} +