Spread the post

Print character without using format specifiers

Print a character or string using following condition.

1) Without using constant string. Exact string are not allowed.

Example : printf("my string");

2) And without use any access specifiers.

Example : printf("%c",'a');

The solution is to use hex escape sequence.

Hex Sequence List

     Hex         Char     Escape     \x21         !     \x22         "     \x23         #     \x24         $     \x25         %     \x26         &     \x27         '     \x28         (     \x29         )     \x30         0     \x31         1     \x32         2     \x33         3     \x34         4     \x35         5     \x36         6     \x37         7     \x38         8     \x39         9     \x40         @     \x41         A     \x42         B     \x43         C     \x44         D     \x45         E     \x46         F     \x47         G     \x48         H     \x49         I     \x50         P     \x51         Q     \x52         R     \x53         S     \x54         T     \x55         U     \x56         V     \x57         W     \x58         X     \x59         Y     \x60         `     \x61         a     \x62         b     \x63         c     \x64         d     \x65         e     \x66         f     \x67         g     \x68         h     \x69         i     \x70         p     \x71         q     \x72         r     \x73         s     \x74         t     \x75         u     \x76         v     \x77         w     \x78         x     \x79         y     \x4a         J     \x4b         K     \x4c         L     \x4d         M     \x4e         N     \x4f         O     \x6a         j     \x6b         k     \x6c         l     \x6d         m     \x6e         n     \x6f         o     \x7A         z     \x7B         {     \x7C         |     \x7D         }     \x7E         ~

C program to print character without using format specifiers.


Output

Spread the post

Recommended Posts: