logo

Courses with this lesson

Why use hexadecimal instead of decimal?

#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char* argv[]) { int arr[4] = { 1, 5, -3, 22000 }; int i; // Decimal for (i = 0; i < 16; i++) { printf("%02hhd ", *(((char*)arr) + i)); } printf("\n"); // Hexadecimal for (i = 0; i < 16; i++) { printf("%02hhx ", *(((char*)arr) + i)); } return 0; }