C - Hexadecimal and Octal Input

Introduction

You can read hexadecimal values from the input stream using the format specifier %x.

For octal values you use %o.

Demo

#define __STDC_WANT_LIB_EXT1__ 1
#include <stdio.h>

int main(void)
{
  int i = 0;// ww  w  .ja  v a 2 s  .com
  int j = 0;
  int k = 0;
  int n = 0;

  printf("Enter three integer values:");
  n = scanf_s(" %d %x %o", &i, &j, &k);

  printf("\nOutput:\n");
  printf("%d values read.\n", n);
  printf("i = %d   j = %d   k = %d\n", i, j, k);
  return 0;
}

Result