C programming questions about dynamic memory allocation

3 C programming questions about dynamic memory allocation
Create a program that reads in flight data from a raw CSV file. Your program should determine how many entries are in the file and allocate the appropriate amount of memory. Each entry should be stored in a struct which matches the flight data given. After the data is read and parsed, print the file contents in a formatted table as seen in the example run.

  1. Create a program that reads in flight data from a raw CSV file. Your program should determine how many entries are in the file and allocate the appropriate amount of memory. Each entry should be stored in a struct which matches the flight data given. After the data is read and parsed, print the file contents in a formatted table as seen in the example run. A sample file can be found on Canvas.

Requirements

  • Your Flight struct should be declared in a header file with a header guard.
  • Read in file name from command line.
  • Check that the file exists.
  • List all contents as seen in the example run.
  • Free any memory allocated.

Flight Data

  • Flight ID char array of size 8
  • Departure Code char array of size 4
  • Destination Code char array of size 4
  • Departure Time int
  • Arrival Time int

Example Run

FLIGHT        DCODE       ACODE       DTIME        ATIME

Don't use plagiarized sources. Get Your Custom Essay on
C programming questions about dynamic memory allocation
Just from $10/Page
Order Essay

SW1234        LAX            DFW            100            300

AA9938        LGA            DAL            300            500

Your code should be saved as problem3.h and problem3.c.

  1. Create a program that allows the user to add strings to an array of strings (char **) as well as the option to remove a string by name.

Requirements

  • Create a menu with four options as seen below.
  • The user should remain in the program until they choose to exit.
  • When adding a string, use the prompts as seen in the example below. Trailing newline characters should be removed.
  • When removing a string, the user should type the string they want to remove. You are to create a function which searches your array of strings for that string. If it is found, it is removed and the array of strings is reallocated. In either case, a statement should notify the user of the result (see example).
  • When listing strings, print each string on a new line.
  • Make sure to free any allocated memory!

Example Run

  1. Add String
  2. Remove String
  3. View Strings
  4. Exit

> 1

Enter string: test test added! 1. Add String

  1. Remove String
  2. View Strings
  3. Exit> 3

test

  1. Add String
  2. Remove String
  3. View Strings
  4. Exit

> 2

Enter string: test1 test1 not found. 1. Add String

  1. Remove String
  2. View Strings
  3. Exit

> 2

Enter string: test test removed!

  1. Add String
  2. Remove String
  3. View Strings
  4. Exit

> 3

No strings!

  1. Add String
  2. Remove String
  3. View Strings
  4. Exit

> 4

Save your code as problem4.c.

  1. Create a program which collects a list of library books. The user should be able to add as many book as they wish and view the collection through a menu. The collection should be sorted by year published (newest first).

Book Struct

typedef struct { char *name; char *author; int year_published;

}

Requirements

  • The Book struct should be defined in a header file with a header guard.
  • The user should stay in the program until they choose to exit.
  • No static memory for the Books should be used. It should be added dynamically as the user enters each one.
  • After each book is added by the user, the array of Books should be sorted using qsort().
  • Make sure to free your memory.

Example Run

  1. Add Book
  2. View Books
  3. Quit

> 1

Enter name: The Hobbit

Enter author: J.R.R. Tolkien

Enter year published: 1937

  1. Add Book
  2. View Books
  3. Quit

> 2

1937 – The Hobbit by J.R.R. Tolkien

  1. Add Book
  2. View Books
  3. Quit

> 1

Enter name: Leviathan Wakes

Enter author: James S. A. Corey

Enter year published: 2011

  1. Add Book
  2. View Books
  3. Quit

> 2

2011 – Leviathan Wakes by James S. A. Corey

1937 – The Hobbit by J.R.R. Tolkien

  1. Add Book
  2. View Books
  3. Quit

> 3

Save your code as problem5.h and problem5.c.

 

Get professional assignment help cheaply

Are you busy and do not have time to handle your assignment? Are you scared that your paper will not make the grade? Do you have responsibilities that may hinder you from turning in your assignment on time? Are you tired and can barely handle your assignment? Are your grades inconsistent?

Whichever your reason may is, it is valid! You can get professional academic help from our service at affordable rates. We have a team of professional academic writers who can handle all your assignments.

Our essay writers are graduates with diplomas, bachelor, masters, Ph.D., and doctorate degrees in various subjects. The minimum requirement to be an essay writer with our essay writing service is to have a college diploma. When assigning your order, we match the paper subject with the area of specialization of the writer.

Why choose our academic writing service?

  • Plagiarism free papers
  • Timely delivery
  • Any deadline
  • Skilled, Experienced Native English Writers
  • Subject-relevant academic writer
  • Adherence to paper instructions
  • Ability to tackle bulk assignments
  • Reasonable prices
  • 24/7 Customer Support
  • Get superb grades consistently

 

 

 

 

 

 

Order a unique copy of this paper
(550 words)

Approximate price: $22

Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

We value our customers and so we ensure that what we do is 100% original..
With us you are guaranteed of quality work done by our qualified experts.Your information and everything that you do with us is kept completely confidential.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

The Product ordered is guaranteed to be original. Orders are checked by the most advanced anti-plagiarism software in the market to assure that the Product is 100% original. The Company has a zero tolerance policy for plagiarism.

Read more

Free-revision policy

The Free Revision policy is a courtesy service that the Company provides to help ensure Customer’s total satisfaction with the completed Order. To receive free revision the Company requires that the Customer provide the request within fourteen (14) days from the first completion date and within a period of thirty (30) days for dissertations.

Read more

Privacy policy

The Company is committed to protect the privacy of the Customer and it will never resell or share any of Customer’s personal information, including credit card data, with any third party. All the online transactions are processed through the secure and reliable online payment systems.

Read more

Fair-cooperation guarantee

By placing an order with us, you agree to the service we provide. We will endear to do all that it takes to deliver a comprehensive paper as per your requirements. We also count on your cooperation to ensure that we deliver on this mandate.

Read more

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Open chat
1
You can contact our live agent via WhatsApp! Via +1 817 953 0426

Feel free to ask questions, clarifications, or discounts available when placing an order.

Order your essay today and save 20% with the discount code VICTORY