Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C LANGUAGE PLEASE. You do not need getopt for this program as there are no options or arguments. Call the source/executable with a useful

IN C LANGUAGE PLEASE.

You do not need getopt for this program as there are no options or arguments. Call the source/executable with a useful name relevant to the activity.

  1. Create a structure with variables for a character, a string pointer, an integer, and a floating point number. [Note: Use Typedef way of creating the structure].
  2. The structure string variable is a "char* stringp". In other words, the structure will have a pointer to a string.
  3. Do not initialize the structure at definition time or define any variables.
  4. Print size (in decimal) of one of these structures.
  5. Allocate memory for 5 structures of this type.
  6. Create 5 pointer variables to the type of structure created - name them appropriately. In other words, each pointer points to a corresponding structure.
  7. Print the difference between the first pointer address and the last address of the 5th structure. Print in decimal.
  8. First Ask the user to enter information for each of these variables one at a time. For each variable tell them what they should enter. (For example: Enter a single character or Enter a floating point number) Read in the information and put it in the structure variables using your dynamically created pointers to those structures. Hint: You can use a subroutine function and pass the pointer(s) created in step 5.
  9. Make sure for the read string you allocate the right amount of memory for the string read from the console - and store into the string pointer.
  10. Print out values for the four variables for the 5 structures using the pointers. Use other printf statements to clearly identify and separate the 5 structures.
  11. In addition print out the addresses of the memory locations that each string pointer points to inside the structure. Print this first.
  12. After printing all the values - free the memory of the structure string pointers and print the same 5 pointers to the structures again.

Output should look something like this:

Size of Structure is = AAAA

Difference between first pointer and last pointer is = BBBB

Structure 1:

Structure 1 pointer: XXXXX1

Character: h

Integer: 8

String: Caryl was here

Floating Point: 4.5

Structure 2:

Structure 2 pointer: XXXXX2

Character: x

Integer: 100

String: Juan is a friend of mine.

Floating Point: 100.2

.....

Structure 5:

Structure 5 pointer: XXXXX5

......

After free the malloc - the pointer are:

Structure 1 pointer: ZZZZZ

Structure 2 pointer: ZZZZZ

etc until Structure 5

Note: Make sure to deliver a Makefile

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

Assess alternative dispute resolution methods.

Answered: 1 week ago