[ create a new paste ] login | about

Link: http://codepad.org/E4C7nTTx    [ raw code | output | fork ]

C++, pasted on Apr 16:
#include <stdio.h>

const int first = 0x21;
const int last = 0x7e;

const int height = 16;
const int begin = (first / height * height);
const int end = (last / height * height + height);
const int width = (end - begin) / height;

int main(void)
{
	int i, j;

	for(i = begin; i < end; i += height)
		printf(" 0x%2x", i);

	printf("\n");

	for(i = 0; i < height; ++i)
	{
		printf("%x", i);

		for(j = 0; j < width; ++j)
		{
			int c = begin + i + j * height;

			(first <= c && c <= last) ? printf( (j == width-1)? "   %c\n" : "   %c ", char(c) ) : printf("     ");
		}

	}
	return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 0x20 0x30 0x40 0x50 0x60 0x70
0        0    @    P    `    p
1   !    1    A    Q    a    q
2   "    2    B    R    b    r
3   #    3    C    S    c    s
4   $    4    D    T    d    t
5   %    5    E    U    e    u
6   &    6    F    V    f    v
7   '    7    G    W    g    w
8   (    8    H    X    h    x
9   )    9    I    Y    i    y
a   *    :    J    Z    j    z
b   +    ;    K    [    k    {
c   ,    <    L    \    l    |
d   -    =    M    ]    m    }
e   .    >    N    ^    n    ~
f   /    ?    O    _    o      


Create a new paste based on this one


Comments: