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);
}

Notes

* As with getchar(), the putchar() function is really a macro. It's defined in the stdio.h file similar to like this:

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

* Even though putchar() isn't a "function," it's still popularly used to send single characters to standard output.

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