Practice: C File I/O
- Download "people.dat" from Files->C FileIO.
- Create a main function that does the following:
- Create strings for name (41 chars), nickname (21 chars),
profession (41 chars), and age (int).
- Open "people.dat" for input and "people.out" for output.
- For each person in the file:
- Read name, nickname, profession, and age for each person.
Each string is on a separate line and may contain multiple
words.
- For each string call your function to remove the newline.
- Call your function to print the person.
- Write a function to check whether a string has a newline right
before the nullbyte. If there is a newline, replace it with a
nullbyte.
- Write a function with two string parms. Your function will set
the second string to the uppercase of the first string.
Call the C library function char toupper(char) which converts
a character to uppercase. Include for the prototype
of toupper.
- Write a function to print a person. The parms are the output FILE
pointer, and the fields for a person. Call your upper function
to change the nickname to uppercase, and then print the person
to the output file in the following format:
Shaquille O'Neill (SHAQ)
profession: basketball player
age: 49
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2021