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, 03.07.2019 23:20
Two technicians are discussing the intake air temperature (iat) sensor. technician a says that the computer uses the iat sensor as a backup to the engine coolant temperature (ect) sensor. technician b says that the powertrain control module (pcm) will subtract the calculated amount of fuel if the air measures hot. who is correct
Answers: 3
question
Engineering, 04.07.2019 18:10
An ideal otto cycle with air as the working fluid has a compression ratio of 8. the minimum and maximum temperatures in the cycle are 300 k and 1340 k. use constant specific heats at room temperature to determine (a) the amount of heat transferred to the air during the heat- addition kj/kg, (b) the thermal efficiency, and (c) the thermal efficiency of a carnot cycle ope limits. process, in rating between the same temperature
Answers: 2
question
Engineering, 04.07.2019 18:20
How much power could a wind turbine produce if it had the following specifications? cp = 0.45 -d=1.2kg/m3 d=50m v 5m/s
Answers: 2
question
Engineering, 04.07.2019 18:20
Aheavily insulated piston-cylinder device contains 0.02 m3 of steam at 300 kpa and 200 °c. 1.2 mpa. d this process. team is now compressed in a reversible manner to a pressure of etermine the entropy change and the work done on the steam during this process
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
Social Studies, 26.08.2019 08:30
question
Mathematics, 26.08.2019 08:30
question
Mathematics, 26.08.2019 08:30
Questions on the website: 13722361