Computer >> Computer tutorials >  >> Programming >> C programming

C program to print characters without using format specifiers


In this article we will see how we can print some characters without using any kind of format specifiers. The format specifiers in C are %d, %f, %c etc.These are used to print characters and numbers in C using the printf() function.

Here we will see another way to print characters without using %c format specifier. This can be done by putting ASCII values directly in hexadecimal form.

Example Code

#include <stdio.h>
main () {
   printf("\x41 \n"); //41 is ASCII of A in Hex
   printf("\x52 \n"); //41 is ASCII of A in Hex
   printf("\x69 \n"); //41 is ASCII of A in Hex
}

Output

A
R
i