c programming
/* CES ASSIGNMENT * Program: Home Electronics Management System * Author: * Student ID: */ #include <stdio.h> #include <stdlib.h> #include <string.h> // The structure that stores the details of each device struct device_type { int deviceID; char deviceName[50]; char deviceLocation[50]; unsigned int deviceState; }; // This function displays the main menu and returns the user's selection int runMenu(); // This function loads a household configuration file "config.dat". // Note, you need to use malloc inside this function to create the configuration, // then return the data and the number of devices to the main program via the // device_type * return type and the numDevices parameter. struct device_type * loadConfig(int * numDevices); // This function saves the current household config to file void saveConfig(struct device_type * dConfig, int numDevices); // This function displays the selected devices to screen void displayConfig(struct device_type * dConfig, int numDevices); // This function finds the index of a single device in the collection void changeDeviceState(struct device_type * dConfig, int numDevices); // This function saves a profile to a user specified file void saveProfile(struct device_type * dConfig, int numDevices); // This function loads a profile from a user specified file void loadProfile(struct device_type * dConfig, int numDevices); int main() { struct device_type * deviceConfig; int numDevices = 0; // Load the device config from file, and then display the menu // using the appropriate function. // // One possible implementation of this is that a function displays // the menu options, and returns the user input. Consequent actions // based on the returned input are handled inside of int main using a // branching statement. The menu should repeat until the program exits. return 0; } int runMenu() { // Display the options described in the assignment specification and // return the user's input } struct device_type * loadConfig(int * numDevices) { // This function should be called once when the program is first run. // // The device config data should be read from file and returned back // to the calling function. } void saveConfig(struct device_type * dConfig, int numDevices) { // This function should be called once, when the program exits. // // Overwrite the file "config.dat" with the current device configuration data // using the same format as the loadConfig function. } void saveProfile(struct device_type * dConfig, int numDevices) { // Save the current device profile to a user specified file. } void loadProfile(struct device_type * dConfig, int numDevices) { // Load a device profile from a user specified file. } void changeDeviceState(struct device_type * dConfig, int numDevices) { // Search for a device by a user entered ID, and hence allow the user // to modify the 'state' attribute of that device. // // BONUS TASK: // You may find it helpful to write an extra function "findDeviceIndexByID" // that will return the index of a device by searching for its ID. } void displayConfig(struct device_type * dConfig, int numDevices) { // Print to screen each device. // Be sure to use proper formatting and to print all details. }