]> hackdaworld.org Git - my-code/beginners.git/commitdiff
added hex to interger calculator :)
authorhackbard <hackbard>
Sat, 4 Jan 2003 14:42:25 +0000 (14:42 +0000)
committerhackbard <hackbard>
Sat, 4 Jan 2003 14:42:25 +0000 (14:42 +0000)
h2i-calc.c [new file with mode: 0644]

diff --git a/h2i-calc.c b/h2i-calc.c
new file mode 100644 (file)
index 0000000..5042af6
--- /dev/null
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+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;
+}
+