Question
Write code to accomplish each of the following: a) Define a structure called part containing unsigned int variable part Number and char array part Name
Write code to accomplish each of the following:
a) Define a structure called part containing unsigned int variable part Number and char array part Name with values that may be as long as 25 characters (including the terminating null character). b) Define Part to be a synonym for the type struct part.
c) Use Part to declare variable data to be of type struct part, array arr[10] to be of type struct part and variable ptr to be of type pointer to struct part.
d) Read a part number and a part name from the keyboard into the individual members of variable data.
e) Assign the address of array arr to the pointer variable ptr.
f) Print the member values of element 3 of array arr using the variable ptr and the structure pointer operator to refer to the members.
g) Define a Union data containing char c, short s, long b, float f and double d.
h) Write a statement that opens the file \"DAmaster.dat\" for both reading and writing and assigns the returned file pointer to nfPtr. Assume that the file contains machine readable (i.e. binary) data with fixed length records.
i) Write a single statement that reads a record from the file \"oldmast.dat\"; file pointer ofPtr refers to this file. The record consists of integer account tNum, string name and floating-point current Balance.
j) Write a statement that writes a record to the file \"newmast.dat\"; file pointer nf Ptr refers to this file. The record consists of the integer account Num, string name and floating-point current Balance.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started