O'Reilly logo

C Primer Plus, Fourth Edition by Stephen Prata

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8

1: putchar(getchar()) is a valid expression; what does it do? Is getchar(putchar()) also valid?
A1: The statement putchar(getchar()); causes the program to read the next input character and to print it; the return value from getchar() is the argument to putchar(). No, getchar(putchar()) is invalid because getchar() doesn't use an argument and putchar() needs one.
2: What would each of the following statements accomplish?
  1. putchar('H');

  2. putchar('\007');

  3. putchar('\n');

  4. putchar('\b');

A2:
  1. Display the H character.

  2. Sound the alert if the system uses ASCII.

  3. Move the cursor to the beginning of the next line.

  4. Backspace.

3: Suppose you have a program count that counts the characters in its input. Devise a command that counts the number of characters in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required