C programming about pointer and dynamic memory allocation

Assignment Help C/C++ Programming
Reference no: EM131258549

Assignment

C Programming about pointer and dynamic memory allocation.

This project will require you to use a structure to hold a record of any kind of data, i.e. address book, library of books as with chapter 14, etc. These records will be used through dynamic memory allocation (malloc) to create and destroy (free) memory. Do not use linked lists for this assignment, we are using dynamic memory allocation to hold records, not using linked lists. The structures will act as a database for your records (structures), and you will need to create enough memory to hold all of your records, but also when you remove records, you will need to allocate new memory, move the data over to that memory space, and free the old memory (instead of using a static size array). No use of arrays is allowed for your structures, but you can use arrays in other places in your program. Your program will prompt for information that will be added to a new structure that will be added when you call the add function. Delete is as simple as just taking the last record out of your database. Your program will also need to hold a static duration memory type that will serve as the counter for how many times the database has changed. Along with the amount of times the database has changed, you will also need to have a variable to hold the number of records in your database, functions to calculate size (records multiplied by sizeof struct), and functions to add, print, and delete records. You will not be required to use lookup functions, print is just the entire database.

To manage your in-memory database, you will need to use some pointers to hold locations of your data. Please take some time to write down examples of where you will need to have pointers. You will need to have at least a pointer to the beginning of your database memory, another to show which record you are on, but think about the need for other pointers when you think about functions that will delete a record, add a record, etc.

You will need a menu to prompt users for the above requirements that may look like:

MENU
=======

1. Print all records
2. Print number of records
3. Print size of database
4. Add record
5. Delete record
6. Print number of accesses to database
7. Exit

Once you have gathered the appropriate information you will need to manipulate the data to hold the data correctly, but we are not using File I/O to maintain state on the data (would require too much time). Your database is a memory only database, so once your program ends, your database is gone. Being this is the case, it will be important to create a header file that has some data in it (5-7 records), so you will not need to enter all the records every time.

You will need to create a design doc as you did with project #1 that describes the reason for the program, the data type and how it will be used (also note the static type for number of accesses to your database) as well as testing criteria.

For this assignment you will need to use "script" to capture you testing your test cases while using your program. Script is a program that will capture everything you do on your screen until you exit the script program. To enter the script program simply type in :

$ script myProject2.out

This will start copying everything you type (stdin) as well as everything that goes to the screen until you type in exit at the $ prompt (you are actually in a new shell, so you won't get logged out)..

Please submit all source/text/script files via the Project #2 Assignment in Moodle.

Please also use the forum for project #2 for Q&A and discussion)

Reference no: EM131258549

Questions Cloud

Lowering of tax rates : The supply-side argument (usually a tool of Republican tax cuts) says that a lowering of tax rates is actually good for tax collections and that tax cuts increase tax collections.
Simplified depiction of an ice rink with an ice resurfacing : Conditions at each point are (C indicates the concen-tration of carbon monoxide, CO):
Identify the customer key issues : Select a product that you like or a product you use. Design a sales presentation/campaign that introduces an idea for the product, or a better way to promote the product. This section should be a minimum of two pages and include the six suggestion..
What is the percentage of time spent working : A random work sample of operators taken over a 160- hour work month at Tele-Marketing, Inc., has produced the following results. What is the percentage of time spent working?
C programming about pointer and dynamic memory allocation : C Programming about pointer and dynamic memory allocation. Once you have gathered the appropriate information you will need to manipulate the data to hold the data correctly.
Example of when an organization opted to write-off : Share a real world example of when an organization opted to write-off a substantial sunk cost and it was a very good idea. Answer must be a minimum of 400 words and cited references appropriately.
Understanding the least-cost rule : Andrew runs a surfing school on the North Shore of Oahu. He has two inputs: surfboards, which he rents from a local shop for $10 per day, and surfing instructors, whom he hires for $50 per day. Andrew has figured out that the marginal physical pro..
Find the percentage of time bob was working : Find the percentage of time Bob was working. - If you want a confidence level of 95%, and if {3% is an acceptable error, what size should the sample be?
Increase in government budget deficits : What is the effect of an increase in government budget deficits on interest rate?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a switch-case statement

Create a script named 'descent.m'. Give a brief but concrete example when switch?case statements should be preferred to if? elseif statements. Use block comments to enter your answer in the script.

  Program that compares the number of possible sequences

Write a c++ program that compares the number of possible sequences of the length L that can be generated. The program must output a formatted list comparing the number of possible sequences for L=5,6,7,8,9. given size N=9

  Write a function that returns a number

Write a test program that prompts the user to enter a phone number as a string. The input number may contain letters. The program translates a letter (upper- or lowercase) to a digit and leaves all other characters intact

  C++ essay & coding

Create codes for the following problem/s. Compile, test run, and edit them if necessary. Include your original .cpp and related file(s) (if any) in a single folder. Compress (zip) the folder and submit the single zipped folder.

  What are data declaration statements

I need an example of a flow chart and specification sheet of a C program.

  Write a class with the following static methods

Wordcount: This method should accept a reference to a String object as an argument and return the number of words contained in the object.

  Explain the steps for building a rudimentary management

Explain the steps for building a rudimentary management system.

  Write a parallel program with mpi

Write a parallel program with MPI that supports the computation - design own decomposition logic on the given problem, such as the number of processes produced, how and where to pass the result from one process to another etc.

  Draw the extensive-form version of game

Consider a game between Joe and Snake. This game takes place in the morning after Joe has had breakfast. Snake can do two things: fight Joe or not. He likes fighting with people who are feeling cowardly and gets a payoff of 1 if he does. Snake, howev..

  Write an interactive program that prompts for a desired sum

Write an interactive program that prompts for a desired sum, then repeatedly rolls two six-sided dice until their sum is the desired sum. Here is the expected dialogue with the user.

  Write a c function that converts a character to upper case.

Write a C function that converts a character to upper case. The function should have the prototype char to_upper(char ch); The characters given as input to the function are assumed to be in the sets {'a', ..., 'z'} and {'A', ... , 'Z' }. Do not use a..

  Program that presents a menu of choices for the user

Write a C program that initially presents a menu of choices for the user.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd