hextools

hextools repository
git clone git://mcdim.xyz/hextools.git
Log | Files | Refs | README

hex.c (417B)


      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 #include <string.h>
      4 #include <inttypes.h>
      5 
      6 #define BUFFER_SIZE 128
      7 
      8 int
      9 main(int argc, char **argv)
     10 {
     11 	if (argc == 2) {
     12 		uintmax_t n = atoi(argv[1]);
     13 		printf("%" PRIxMAX "\n", n);
     14 		
     15 		return 0;
     16 	}
     17 
     18 	char buffer[BUFFER_SIZE];
     19 	while (fgets(buffer, sizeof(buffer), stdin)) {
     20 		strtok(buffer, "\n");
     21 		uintmax_t n = atoi(buffer);
     22 		printf("%" PRIxMAX "\n", n);
     23 	}
     24 
     25 	return 0;
     26 }