Q:

How can I print a NUL character without a space in C?

I have a situation where I have to print out a NUL character if there is no action in a part of my program. Take for example the code below:
char x = '\0';

...

printf("@%c@\n", x);

I want it to print this:

@@

but it prints out

@ @

Whats the correct way not to have the \0 character printed out a space as above?

A:

if (x == 0)
    printf("@@\n");
else
    printf("@%c@\n", x);

It's not actually printing a space, it actually outputs the \0. It's just that whatever you're viewing the text with is displaying the \0 as a space.

