subject
Engineering, 09.12.2019 19:31 mawawakaiii

The purpose of this assignment is to provide practice programming using structs and pointers in c programming language. your program will accept user input and store it in a dynamic array of structs. first, you will define a structure to describe a location. your program will prompt the user for the initial size of the array. it will then allocate memory from the heap for an array called locationarray. once this is done, your program will allow the user to enter data for as many locations as s/he wishes. if the user wishes to add more locations than the initial size of the array will allow, you will use calls to malloc() and memcpy() to increase the size of the array so that the user can continue to add more locations. see the instructions below for specific details. specifications: define a struct appropriate for holding location information. at minimum, this should include a location number (an integer), id (a string containing no more than 15 characters), a description (a string containing no more than 50 characters) and a latitude and longitude (both floating point values). ask the user for the number of locations, and use this number as the initial size of your locationarray. (hint: for easier testing, use a small number, such as two or three.)allocate an appropriate amount of memory from the heap to create a dynamic array (named locationarray) of location structs, large enough to hold the number of locations entered by the user. provide a menu that allows the user to choose among the following options: add a location to locationarray - this will prompt the user to enter information about the location (id, description, lat/lon), and save this in the next uninitialized element in locationarray. print the current list of locations - this will print all elements of each initialized location struct)quit the program create a function called "resizearray" to be used whenever the number of locations to be added to locationarray would exceed the current bounds of the array. the user should not be aware that the size of the array is changing. rather, s/he should simply be allowed to keep adding locations until s/he is done, and resizearray should be called (transparently to the user) whenever the number of locations to be added would exceed the bounds of the array so that the user may add as many locations as s/he likes. each call to resizearray should double the size of the existing locationarray. if by any chance all heap memory is exhausted, an appropriate error message should be issued to the user. make sure you test your function by adding more locations than originally requested at the start of your program. be sure to include comments within your code that explain in high-level terms what the various parts of your code are doing. other specifications: you may not use realloc() for this assignment. with the exception of those specifically disallowed, use whatever functions, parameters and return statements you wish to organize your code and ensure that it works correctly.

ansver
Answers: 3

Another question on Engineering

question
Engineering, 04.07.2019 18:10
Apump is used to circulate hot water in a home heating system. water enters the well-insulated pump operating at steady state at a rate of 0.42 gal/min. the inlet pressure and temperature are 14.7 lbf/in.2, and 180°f, respectively; at the exit the pressure is 60 lbf/in.2 the pump requires 1/15 hp of power input. water can be modeled as an incompressible substance with constant density of 60.58 lb/ft3 and constant specific heat of 1 btu/lb or. neglecting kinetic and potential energy effects, determine the temperature change, in °r, as the water flows through the pump.
Answers: 1
question
Engineering, 04.07.2019 18:10
Coiled springs ought to be very strong and stiff. si3n4 is a strong, stiff material. would you select this material for a spring? explain.
Answers: 2
question
Engineering, 04.07.2019 19:10
Asteel wire of 2 mm diameter is fixed between two points located 2 m apart. the tensile force in the wire is 250n, if its density of steel is given by 7830 kg/m3 the fundamental frequency of vibration hz? ?
Answers: 3
question
Engineering, 06.07.2019 03:10
Different between boring and turning?
Answers: 1
You know the right answer?
The purpose of this assignment is to provide practice programming using structs and pointers in c pr...
Questions
question
Physics, 18.03.2021 01:10
Questions on the website: 13722367