Subversion Repositories Vertical

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
#include <stdio.h>
2
 
3
#define POS "@@C\x1"
4
 
5
#define SIZE 23
6
 
7
#define SILLY(x) (SIZE + x)
8
 
9
#define SILLY2(x) (SIZE * 2 + x * 2)
10
 
11
char s1[] = "m\000"; /* character 'm' followed by char containing 0 octal */
12
 
13
char s2[] = "n\x05"; /* character 'm' followed by char containing 05 hex */
14
 
15
char s3[] = "o\a"; /* \attention = BELL */
16
 
17
char s4[] = "p\r"; /* \return    = CR */
18
 
19
char s5[] = "q\n"; /* \newline   = LF */
20
 
21
char s6[] = "r\t"; /* \tab       = TAB */
22
 
23
char s7[] = "s\f"; /* \form feed = FF (but in fact */
24
 
25
/* you need ANSI escape codes on UNIX  */
26
 
27
char s8[] = POS;
28
 
29
/* function to print out a character array character by character with
30
 
31
   each character in () unless its code is less than 31 , then the hex code
32
 
33
   for that character */
34
 
35
/* str is pointer to first character */
36
 
37
/* count is the character count */
38
 
39
void list (char *str, int count)
40
{
41
        printf ("string in hex ");
42
 
43
        for (; count > 0; count--)
44
 
45
                printf (" (%c) %02X", *str > 31 ? *str : '?', *str++);
46
 
47
        printf ("\n");
48
}
49
 
50
void main (void)
51
{
52
        int x;
53
 
54
        x = SILLY (3);
55
 
56
        list (s1, 2);
57
 
58
        list (s2, 2);
59
 
60
        list (s3, 2);
61
 
62
        list (s4, 2);
63
 
64
        list (s5, 2);
65
 
66
        list (s6, 2);
67
 
68
        list (s7, 2);
69
 
70
        list (s8, 4);
71
}