/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <stdio.h>
typedef struct
{
int year;
int month;
int day;
int hour;
int minute;
int second;
} TimeStruct;
void GetDateTime1 (int *year, int *month, int *day, int *hour, int *minute, int *second)
{
*year = 2023;
*month = 8;
*day = 19;
*hour = 4;
*minute = 20;
*second = 0;
}
void GetDateTime2 (TimeStruct *timePtr)
{
timePtr->year = 2023;
timePtr->month = 8;
timePtr->day = 19;
timePtr->hour = 4;
timePtr->minute = 20;
timePtr->second = 0;
}
TimeStruct *GetDateTime3 (void)
{
static TimeStruct s_time;
s_time.year = 2023;
s_time.month = 8;
s_time.day = 19;
s_time.hour = 4;
s_time.minute = 20;
s_time.second = 0;
return &s_time;
}
TimeStruct GetDateTime4 (void)
{
TimeStruct time;
time.year = 2023;
time.month = 8;
time.day = 19;
time.hour = 4;
time.minute = 20;
time.second = 0;
return time;
}
int main()
{
int year, month, day, hour, minute, second;
GetDateTime1 (&year, &month, &day, &hour, &minute, &second);
printf ("GetDateTime1: %d/%d/%d %02d:%02d:%02d\n",
year, month, day, hour, minute, second);
TimeStruct time;
GetDateTime2 (&time);
printf ("GetDateTime2: %d/%d/%d %02d:%02d:%02d\n",
time.year, time.month, time.day,
time.hour, time.minute, time.second);
TimeStruct *timePtr;
timePtr = GetDateTime3 ();
printf ("GetDateTime3: %d/%d/%d %02d:%02d:%02d\n",
timePtr->year, timePtr->month, timePtr->day,
timePtr->hour, timePtr->minute, timePtr->second);
//TimeStruct time;
time = GetDateTime4 ();
printf ("GetDateTime4: %d/%d/%d %02d:%02d:%02d\n",
time.year, time.month, time.day,
time.hour, time.minute, time.second);
return 0;
}