Skip to content

Latest commit

 

History

History

README.md

Chapter 6. Reading and Writing Simple Records: Use the Concepts

  • Add another data member to the person structure defined in this chapter, and rewrite the reading and writing functions and programs to take them into account. Remember to reassemble and relink your files before running your programs:

  • Create a program that uses a loop to write 30 identical records to a file:

  • Create a program to find the largest age in the file and return that age as the status code of the program:

  • Create a program to find the smallest age in the file and return that age as the status code of the program:

  • Research the lseek system call. Rewrite the add-year program to open the source file for both reading and writing (use $2 for the read/write mode), and write the modified records back to the same file they were read from:

  • Write a program that will add a single record to the file by reading the data from the keyboard. Remember, you will have to make sure that the data has at least one null character at the end, and you need to have a way for the user to indicate they are done typing. Because we have not gotten into characters to numbers conversion, you will not be able to read the age in from the keyboard, so you’ll have to have a default age:

  • Write a function called compare-strings that will compare two strings up to 5 characters. Then write a program that allows the user to enter 5 characters, and have the program return all records whose first name starts with those 5 characters:

Questions: