Next: Ceilidh - On Line C Tutoring System Up: UNIX and C Previous: Times Up!!

Exercises

  1. Write a program to print the lines of a file which contain a word given as the program argument (a simple version of grep UNIX utility).

    (unit8:File Input/Output:ex.grp)

  2. Write a program to list the files given as arguments, stopping every 20 lines until a key is hit.(a simple version of more UNIX utility)

  3. Use popen() to pipe the rwho (UNIX command) output into more (UNIX command) in a C program.

  4. Setup a two-way communication between parent and child processes in a C program. i.e. both can send and receive signals.

  5. Write a C program to emulate the ls -l UNIX command that prints all files in a current directory and lists access privileges etc. DO NOT simply exec ls -l from the program.

  6. Write a C program to produce a series of floating point random numbers in the ranges (a) 0.0 - 1.0
    (b) 0.0 - n where n is any floating point value. The seed should be set so that a unique sequence is guaranteed.

  7. Write a C program that times a fragment of code in milliseconds.

  8. Write a program that will list all files in a current directory and all files in subsequent sub directories.

  9. Write a program that will only list subdirectories in alphabetical order.

  10. Write a program that shows the user all his/her C source programs and then prompts interactively as to whether others should be granted read permission; if affirmative such permission should be granted.

  11. Write a program that gives the user the opportunity to remove any or all of the files in a current working directory. The name of the file should appear followed by a prompt as to whether it should be removed.



Next: Ceilidh - On Line C Tutoring System Up: UNIX and C Previous: Times Up!!


Dave.Marshall@cm.cf.ac.uk
Wed Sep 14 10:06:31 BST 1994