Question
This is an exercise about C programming.Please add some explanations with the answer.Thanks a lot. The codes are as below: 1. // lab3exe_G.c #include #include
This is an exercise about C programming.Please add some explanations with the answer.Thanks a lot.
The codes are as below:
1.
// lab3exe_G.c
#include
#include "lab3exe_G.h"
const Date cd = {1, 1, 1970};
int main() {
Timestamp *tsp;
Time t = {0, 0, 24};
Timestamp ts = {cd, &t};
tsp = & ts;
change_date_time(&tsp->date, &t);
printf("Program Terminted. ");
return 0;
}
void change_date_time(Date *arg1, Time *arg2){
arg1 -> day = 29;
arg1 -> month = 10;
arg1 -> year = 2016;
(*arg2).second = 5;
(*arg2).minute = 59;
(*arg2).hour = 23;
// Point one
}
2.
// lab3exe_G.h
#ifndef lab3ExG_h
#define lab3ExG_h
typedef struct Date {
int day, month, year;
}Date;
typedef struct Time {
int second, minute, hour;
}Time;
typedef struct Timestamp{
Date date;
Time *time;
}Timestamp;
void change_date_time(Date *d, Time *t);
#endif /* lab3ExG_h */
The codes are as above, please note that there are two files.
Exercise G: Nested Structure This is post-lab exercise What to Do: Download file lab3exe G.c and lab3exe G. h from D2L. In the file lab3exe_G.h there are two structures called Time and Date and a third structure called Timest amp that nests the other two structures. Study the files to understand what the program does. Then draw memory diagrams for point one in the file 1ab3exe G.c What to Submit: Submit your diagram
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