The first thing the program is required to do is load in


The first thing the program is required to do is load in the household configuration file, with the following filename:
housecfg.dat

If the file is not found, or there are any errors in reading the file data, the program should report this and then terminate.
The data contained in the file should be loaded into an array of structures. The array should be declared in the main function, although the file load should have a function of its own. Note that it is recommended to use dynamic memory allocation for this task, as static memory allocation will result in a loss of marks.

You may assume the file will follow the following format:
[Number of household devices]
[Unique Device ID]
[Device Name]
[Device Location]
[Device State]
...
...
[Unique Device ID]
[Device Name]
[Device Location]
[Device State]

The ... represents repeated intermediate devices.

The fields are described as follows:
[Number of household devices] - This is the total number of devices stored in the file
[Unique Device ID] - This is an integer identifier for the current device, useful for storing specific information about the device's state.
[Device Name] - This is a string specifying the name of the device. For example, this may be "TV".
[Device Location] - This is a string specifying the room of the house that the device is located in. For example, "Lounge" or "Dining".
[Device State] - This is an integer specifying the current state of the device. Note that for this assignment, we will only use two states; on and off.The on state is represented by a 1. The off state is represented by a 0.

Below is an example of a household configuration file:
2
0
TV
Lounge
0
1
Computer
Study
1
N.B. If the sample file is copied from windows into putty, the file newline formatting may be incorrect. Use the following command to change the format of the file from windows to Unix
dos2unix.

Attachment:- programing.rar

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: The first thing the program is required to do is load in
Reference No:- TGS01093091

Expected delivery within 24 Hours