#include <stdint.h>
#include "print_n.h"
int main() {
int value = 3;
print_n('a');
print_n((signed char)-15);
print_n((unsigned char)15);
print_n((signed short)-15);
print_n((unsigned short)15);
print_n(-15);
print_n(15U);
print_n(-15L);
print_n(15UL);
print_n(-15LL);
print_n(15ULL);
print_n(3.05f);
print_n(3.05);
print_n(&value);
return 0;
}
#include <stdio.h>
enum struct Kind {
Int,
UInt,
Float,
Char,
Ptr,
};
template<size_t size, Kind kind>
const char *prefix() = delete;
template<> const char *prefix<1, Kind::Char>() { return "char"; }
template<> const char *prefix<1, Kind::Int>() { return "int8_t"; }
template<> const char *prefix<1, Kind::UInt>() { return "uint8_t"; }
template<> const char *prefix<2, Kind::Int>() { return "int16_t"; }
template<> const char *prefix<2, Kind::UInt>() { return "uint16_t"; }
template<> const char *prefix<4, Kind::Int>() { return "int32_t"; }
template<> const char *prefix<4, Kind::UInt>() { return "uint32_t"; }
template<> const char *prefix<8, Kind::Int>() { return "int64_t"; }
template<> const char *prefix<8, Kind::UInt>() { return "uint64_t"; }
template<> const char *prefix<4, Kind::Float>() { return "float"; }
template<> const char *prefix<8, Kind::Float>() { return "double"; }
template<> const char *prefix<4, Kind::Ptr>() { return "void *"; }
template<> const char *prefix<8, Kind::Ptr>() { return "void *"; }
void print_n(char n) { printf("%s: %c\n", prefix<sizeof(n), Kind::Char>(), n); }
void print_n(signed char n) { printf("%s: %hhi\n", prefix<sizeof(n), Kind::Int>(), n); }
void print_n(unsigned char n) { printf("%s: %hhu\n", prefix<sizeof(n), Kind::UInt>(), n); }
void print_n(signed short n) { printf("%s: %hi\n", prefix<sizeof(n), Kind::Int>(), n); }
void print_n(unsigned short n) { printf("%s: %hu\n", prefix<sizeof(n), Kind::UInt>(), n); }
void print_n(signed int n) { printf("%s: %i\n", prefix<sizeof(n), Kind::Int>(), n); }
void print_n(unsigned int n) { printf("%s: %u\n", prefix<sizeof(n), Kind::UInt>(), n); }
void print_n(signed long n) { printf("%s: %li\n", prefix<sizeof(n), Kind::Int>(), n); }
void print_n(unsigned long n) { printf("%s: %lu\n", prefix<sizeof(n), Kind::UInt>(), n); }
void print_n(signed long long n) { printf("%s: %lli\n", prefix<sizeof(n), Kind::Int>(), n); }
void print_n(unsigned long long n) { printf("%s: %llu\n", prefix<sizeof(n), Kind::UInt>(), n); }
void print_n(float n) { printf("%s: %g\n", prefix<sizeof(n), Kind::Float>(), n); }
void print_n(double n) { printf("%s: %g\n", prefix<sizeof(n), Kind::Float>(), n); }
void print_n(void *n) { printf("%s: 0x%.16zX\n", prefix<sizeof(n), Kind::Ptr>(), (size_t)n); }
void print_n(char *s, char n) { printf("%s: %c\n", s, n); }
void print_n(char *s, signed char n) { printf("%s: %hhi\n", s, n); }
void print_n(char *s, unsigned char n) { printf("%s: %hhu\n", s, n); }
void print_n(char *s, signed short n) { printf("%s: %hi\n", s, n); }
void print_n(char *s, unsigned short n) { printf("%s: %hu\n", s, n); }
void print_n(char *s, signed int n) { printf("%s: %i\n", s, n); }
void print_n(char *s, unsigned int n) { printf("%s: %u\n", s, n); }
void print_n(char *s, signed long n) { printf("%s: %li\n", s, n); }
void print_n(char *s, unsigned long n) { printf("%s: %lu\n", s, n); }
void print_n(char *s, signed long long n) { printf("%s: %lli\n", s, n); }
void print_n(char *s, unsigned long long n) { printf("%s: %llu\n", s, n); }
void print_n(char *s, float n) { printf("%s: %g\n", s, n); }
void print_n(char *s, double n) { printf("%s: %g\n", s, n); }
void print_n(char *s, void *n) { printf("%s: 0x%.16zX\n", s, (size_t)n); }
#pragma once
void print_n(char n);
void print_n(signed char n);
void print_n(unsigned char n);
void print_n(signed short n);
void print_n(unsigned short n);
void print_n(signed int n);
void print_n(unsigned int n);
void print_n(signed long n);
void print_n(unsigned long n);
void print_n(signed long long n);
void print_n(unsigned long long n);
void print_n(float n);
void print_n(double n);
void print_n(void *n);
void print_n(char *s, char n);
void print_n(char *s, signed char n);
void print_n(char *s, unsigned char n);
void print_n(char *s, signed short n);
void print_n(char *s, unsigned short n);
void print_n(char *s, signed int n);
void print_n(char *s, unsigned int n);
void print_n(char *s, signed long n);
void print_n(char *s, unsigned long n);
void print_n(char *s, signed long long n);
void print_n(char *s, unsigned long long n);
void print_n(char *s, float n);
void print_n(char *s, double n);
void print_n(char *s, void *n);