[go: up one dir, main page]

Menu

[4cf102]: / sample.cpp  Maximize  Restore  History

Download this file

107 lines (89 with data), 1.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
#include <cstdio>
void print_type(double x)
{
printf("double\n");
}
void print_type(float x)
{
printf("float\n");
}
void print_type(unsigned long x)
{
printf("unsigned long\n");
}
void print_type(long x)
{
printf("long\n");
}
void print_type(unsigned int x)
{
printf("unsigned int\n");
}
void print_type(int x)
{
printf("int\n");
}
void print_type(unsigned short x)
{
printf("unsigned short\n");
}
void print_type(short x)
{
printf("short\n");
}
void print_type(signed char x)
{
printf("signed char\n");
}
void print_type(unsigned char x)
{
printf("unsigned char\n");
}
void print_type(char x)
{
printf("char\n");
}
void print_type(bool x)
{
printf("bool\n");
}
template <class T>
void dump ( T v )
{
T x = v;
int i;
print_type(x);
for ( i = 0; i < sizeof(T); i++ ) {
printf("%02x ",((unsigned char *)&x)[i]);
}
printf("\n");
}
int main()
{
double y = 1.75;
float x = 1.5;
unsigned long ul = 125;
long l = 125;
unsigned int ui = 125;
int i = 125;
unsigned short us = 125;
short s = 125;
signed char sc = 125;
unsigned char uc = 125;
char c = 125;
bool b = true;
dump(y);
dump(x);
dump(ul);
dump(l);
dump(ui);
dump(i);
dump(us);
dump(s);
dump(sc);
dump(uc);
dump(c);
dump(b);
dump((ul << 3) + 1);
return 0;
}