Node:Questions 16, Previous:Low-level file routines, Up:Input and output



Questions

  1. What are the following?
    1. File name
    2. File descriptor
    3. Stream
  2. What is a pseudo-device name?
  3. Where does stdin usually get its input?
  4. Where does stdout usually send its output?
  5. Write a program that simply prints out the following string to the screen: 6.23e+00.
  6. Investigate what happens when you type the wrong conversion specifier in a program. e.g. try printing an integer with %f or a floating point number with %c. This is bound to go wrong - but how will it go wrong?
  7. What is wrong with the following statements?
    1. printf (x);
    2. printf ("%d");
    3. printf ();
    4. printf ("Number = %d");
    Hint: if you don't know, try them in a program!
  8. What is a whitespace character?
  9. Write a program that aceepts two integers from the user, multiplies them together, and prints the answer on your printer. Try to make the input as safe as possible.
  10. Write a program that simply echoes all the input to the output.
  11. Write a program that strips all space characters out of the input and replaces each string of them with a single newline character.
  12. The scanf function always takes pointer arguments. True or false?
  13. What is the basic difference between high-level and low-level file routines?
  14. Write a statement that opens a high level file for reading.
  15. Write a statement that opens a low level file for writing.
  16. Write a program that checks for illegal characters in text files. The only valid characters are ASCII codes 10, 13, and 32..126.
  17. What statement performs formatted writing to text files?
  18. Poke around in the header files on your system so you can see what is defined where.