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
Afour cylinder four-stroke in-line engine has a stroke of 160mm, connecting rod length of 150mm, a reciprocating mass of 3kg and its firing order is 1-3-4-2. the spacing between cylinders is 100mm. i. show that the engine is in balance with regard to the primary inertia forces and primary 3. a and secondary inertia couples. li determine the out of balance secondary inertia force ii. propose ways of balancing this out of balance force and discuss the challenges that will arise
Answers: 3
question
Engineering, 04.07.2019 18:20
For a gate width of 2 m into the paper, determine the force required to hold the gate abc at its location.
Answers: 1
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
question
Engineering, 04.07.2019 19:10
Apressure vessel with an r/t 20 cannot be treated as thin walled vessel. a)-trune b)- false
Answers: 3
You know the right answer?
The purpose of this assignment is to provide practice programming using structs and pointers in c pr...
Questions
question
Spanish, 22.04.2021 17:50
question
Mathematics, 22.04.2021 17:50
question
Chemistry, 22.04.2021 17:50
question
English, 22.04.2021 17:50
Questions on the website: 13722363