Last active
June 6, 2021 16:12
-
-
Save giljr/5d1d9a773b6abf0bc5ba21ab3b9eeb43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define TRUE 1 | |
#define FALSE 0 | |
struct Date | |
{ | |
unsigned int day; | |
unsigned int month; | |
unsigned int year; | |
unsigned int status; | |
}; | |
struct Date date_init(struct Date *dt) | |
{ | |
dt -> day = 1; | |
dt -> month = 1; | |
dt -> year = 2020; | |
dt -> status = 1; | |
return *dt; | |
} | |
int validate() | |
{ | |
// Hardware Serial initialization stake goes here! | |
return FALSE; | |
//return TRUE; | |
} | |
struct Date date_modify(struct Date *dt, int _day, int _month, int _year) | |
{ | |
dt -> _day; // = 28; | |
dt -> _month; // = 11; | |
dt -> _year; //= 2020; | |
// or | |
//(*dt)._day; // = 28; | |
//(*dt)._month; // = 11; | |
//(*dt)._year; // = 2020; | |
if(validate()) | |
{ | |
dt -> status = TRUE; | |
//(*dt).status = 1; | |
} else { | |
dt -> status = FALSE; | |
//(*dt).status = 0; | |
} | |
return *dt; | |
} | |
void date_print(const struct Date *dt) | |
{ | |
if(dt->status) | |
{ | |
//printf("Date:\nDay=%d\nMonth=%d\nYear=%d\nStatus=%d\n\n", dt.day, dt.month, dt.year,dt.status); | |
//printf("Date:\nDay=%d\nMonth=%d\nYear=%d\nStatus=%d", (*dt).day, (*dt).month, (*dt).year,(*dt).status); | |
printf("Date:\nDay=%d\nMonth=%d\nYear=%d\nStatus=%d\n\n", dt->day, dt->month, dt->year, dt->status); | |
} | |
else | |
{ | |
printf("Error: Object initialization Problem:\\\nPlease, Verify your Serial Port of your Iot Hardware.\n"); | |
} | |
} | |
main() | |
{ | |
struct Date clock; | |
//UART_Init(9600); | |
clock = date_init(&clock); | |
date_print(&clock); | |
clock = date_modify(&clock, 28, 11, 2020); | |
//clock.day = 28; | |
//clock.month = 11; | |
//clock.year = 2020; | |
//clock.status = 0; | |
date_print(&clock); | |
//printf("Date:\nDay=%d\nMonth=%d\nYear=%d\nStatus=%d", dt.day, dt.month, dt.year,dt.status); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment