Question
Program 1 instructions are there for reference only. In C Language Create a program studentstruct.c to create and display a struct from parameters from a
Program 1 instructions are there for reference only.
In C Language
Create a program studentstruct.c to create and display a struct from parameters from a command line.
Use getopt for the program to enter values. Make the executable name studentstruct
Commandline should be: $ studentstruct -i "studentid" -m "month" -d "day" -y "year" -c "class" -g "gpa" FirstName LastName.
- -c and -g are optional with a default value other options are mandatory.
- -c default is freshman or 1
- -g default is 3.00
Create a structure for a student, with a nested structure for DOB as shown below. The structure should have the following information:
- First name string(30)
- Last name string(30)
- Student ID string(7) With mandatory seven digits.
- DOB structure:
Month integer (1-12)
Day integer (1-31) months with different days don't matter keep it 1 - 31
Year integer (4-digits)
5. Student year, (Freshman (1), Sophomore (2), Junior (3), Senior (4)) integer
6. Current GPA float
- You will need a structure for the DOB to include in the student structure. Store the structure on a .h file
- Fill the structure with some data from getopt. Do this on the main code.
- Make sure proper values are send to the command line - check for errors. Notice DOB is all integers. Make sure to translate the month integer into a 3 letter month - 1 - Jan ; 2- Feb ... 12 - Dec - the same with Student year translate 1 - Freshman, 2- Sophomore etc.
- Use a subroutine to Print the values in the student record using direct selection in a nicely formatted manner.
For example:
. studentstruct -i 2023316 -m 12 -d 21 -y 2053 -c 4 -g 2.74 Porcha Sares
Name: Porcha Sares
Student ID: 2023316
DOB: Dec/21/2053
Standing: Senior
GPA: 2.74
Make a makefile for the .c and .h files as well as the main.c program
Program 2
- Similar to studentstruct.c from program 1, studentstruct2.c but will the following modifications.
- The program only takes one parameter - which is how many students records will be printed (at least test with a max of 5). You can use argc argv for this parameter. Default can be 5 if no value is entered. Check for errors.
- The student records created will be pre-allocated - you will have 5 structures even though on any run you may use only 1 through 5 depending on input.
- You will prompt the user to enter the values to populate the structure records. Check for valid input.
- The records address will be stored in an array.
- Use a subroutine function on a separate file to print the records - printRecords.c - pass the array to the function and the number of records to print. You can use a modified print subroutine from previous program.
examples
.studentstruct2 5
.studentstruct2 3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started