Exercises4

advertisement
Exercise 1: Created on disk and display on the screen the file named
"INFORM.TXT". The file is structured as follows :
Number (integer)
FirstName (string)
LastName (string)
The number of records to be created is to enter by the user.
Exercise 2:
1. Define an input file handle called input_file, which is a pointer to a type FILE.
2. Using input_file, open the file results.dat for read mode as a text file.
3. Write C statements which tests to see if input_file has opened the data file
successfully. If not, print an error message and exit the program.
4. Write C code which will read a line of characters (terminated by a \n)
from input_file into a character array called buffer. NULL terminate the buffer upon
reading a \n.
5. Close the file associated with input_file.
Exercise 3:
Delete all records in INFORM.TXT:
a) whose serial number ends with 8
b) whose name is "Paul" (use strcmp)
c) whose name is a palindrome. PALI help define a function that provides the result 1
if the string passed as a parameter is a palindrome, otherwise zero.
Save the new file each time under the name INFBIS.TXT.
Download