Solution for Exercise 7-5

ex0705

#include <stdio.h>

int main()
{
    int ch;

    printf("Press Enter: ");
    getchar();
    ch = 'H';
    putchar(ch);
    ch = 'i';
    putchar(ch);
    putchar('!');
    return(0);
}

Output

Hi!

Notes

* The output above doesn't terminate with a newline character.

* As with getchar(), the putchar() function can be a macro. If so, it's defined in the stdio.h file similar to like this:

* So the real function that displays a character is the putc() function. As defined above, x is an int value and stdout is the standard output device.

* The character displayed appears at the next position on the screen — or wherever output is redirected. It's not followed automatically by a newline.