Engineering
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.

answer
Answers: 3

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:20, alexis9263
Have a greater impact on maintenance productivity than any other support group. (clo5) a)-the top management b)-inventory and purchasing c)-sub-contracting d)-cmms
Answers: 2
image
Engineering, 04.07.2019 18:20, kendrawalraven
The characteristic roots of a dynamic system are: 1.7920 1.8160 i, -1.7920 1.8160 i, -0.4160 what is the order of this system? what are the settling time and damping ratio of the system?
Answers: 3
image
Engineering, 04.07.2019 19:10, kimmy6973
What is creep? what is stress relaxation?
Answers: 1
image
Engineering, 04.07.2019 19:20, holaadios222lol
Apiping systems consists of 6 m of 6-std type k and 12 m of 4-std type k, both drawn copper tubing. the system conveys ethylene glycol at a rate of 0.013 m3/s. the pressure drop across the system is to be calculated. there are two 90° elbows in the 6-in pipe, a reduction from the 6-in pipe to the 4-in pipe and four 90° elbows in the 4-in pipe. all fittings are soldered (same as flanged) and regular. the inlet and outlet of the system are at the same height.
Answers: 1
Do you know the correct answer?
The purpose of this assignment is to provide practice programming using structs and pointers in c pr...

Questions in other subjects:

Konu
Social Studies, 14.09.2020 14:01
Konu
Mathematics, 14.09.2020 14:01
Konu
Mathematics, 14.09.2020 14:01
Konu
English, 14.09.2020 14:01
Konu
Mathematics, 14.09.2020 14:01
Konu
Mathematics, 14.09.2020 14:01
Konu
Mathematics, 14.09.2020 14:01
Konu
Mathematics, 14.09.2020 14:01
Konu
Social Studies, 14.09.2020 14:01
Konu
Arts, 14.09.2020 14:01