getdate() and setdate() function in C with Examples Last Updated : 13 May, 2022 Comments Improve Suggest changes Like Article Like Report setdate() Method: getdate() function is defined in dos.h header file. This function fills the date structure *dt with the system's current date. Syntax struct date dt; getdate(&dt); Parameter: This function accepts a single parameter dt which is the object of structure date. Return Value: This method does not return anything. It just gets the system date and sets it in the specified structure. Note: The <dos.h> header file used in this tutorial works only on dos-based systems and will not work on Linux-based systems. Program 1: Implementation of getdate() function C // C program to demonstrate getdate() method #include <dos.h> #include <stdio.h> int main() { struct date dt; // This function is used to get // system's current date getdate(&dt); printf("System's current date\n"); printf("%d/%d/%d", dt.da_day, dt.da_mon, dt.da_year); return 0; } Output: setdate() Method: setdate() function is defined in dos.h header file. This function sets the system date to the date in *dt. Syntax struct date dt; setdate(&dt) Parameter: This function accepts a single parameter dt which is the object of structure date that has to be set as the system date. Return Value: This method do not returns anything. It just sets the system date as specified. Program 1: Implementation of setdate() function C // C program to demonstrate setdate() method #include <dos.h> #include <stdio.h> int main() { struct date dt; // This function is used to get // system's current date getdate(&dt); printf("System's current date\n"); printf("%d/%d/%d", dt.da_day, dt.da_mon, dt.da_year); printf("Enter date in the format (date month year)\n"); scanf("%d%d%d", &dt.da_day, &dt.da_mon, &dt.da_year); // This function is used to change // system's current date setdate(&dt); printf("System's new date (dd/mm/yyyy)\n") printf("%d%d%d", dt.da_day, dt.da_mon, dt.da_year); return 0; } Output: Note: These programs are run in TurboC/C++ compiler Comment More infoAdvertise with us Next Article getdate() and setdate() function in C with Examples sanjeev2552 Follow Improve Article Tags : C Language C-Functions Similar Reads asctime() and asctime_s() functions in C with Examples asctime() function The asctime() function returns the pointer to the string that contains the information stored in the structure of the struct tm type. This function is used to return the local time defined by the system in string format. This function is defined in <time.h> header file. Synt 3 min read free() Function in C Library With Examples The free() function in C is used to free or deallocate the dynamically allocated memory and helps in reducing memory wastage. The C free() function cannot be used to free the statically allocated memory (e.g., local variables) or memory allocated on the stack. It can only be used to deallocate the h 3 min read Predefined Macros in C with Examples According to C89 Standard, C programming language has following predefined macros: __LINE__ Macro: __LINE__ macro contains the current line number of the program in the compilation. It gives the line number where it is called. It is used in generating log statements, error messages, throwing excepti 4 min read Formatted and Unformatted Input/Output functions in C with Examples In C language, the Input/Output (I/O) functions are part of the standard library, and these functions are used for interacting with the user or other systems, to perform operations such as reading input and printing output. These functions provide ways to read data from files and other input devices 7 min read C Function Arguments and Function Return Values Prerequisite: Functions in CA function in C can be called either with arguments or without arguments. These functions may or may not return values to the calling functions. All C functions can be called either with arguments or without arguments in a C program. Also, they may or may not return any v 5 min read strftime() function in C/C++ strftime() is a function in C which is used to format date and time. It comes under the header file time.h, which also contains a structure named struct tm which is used to hold the time and date. The syntax of strftime() is as shown below : size_t strftime(char *s, size_t max, const char *format, c 3 min read How to Declare a Pointer to a Function? A pointer to a function is similar to a pointer to a variable. However, instead of pointing to a variable, it points to the address of a function. This allows the function to be called indirectly, which is useful in situations like callback functions or event-driven programming.In this article, we w 2 min read User-Defined Function in C A user-defined function is a type of function in C language that is defined by the user himself to perform some specific task. It provides code reusability and modularity to our program. User-defined functions are different from built-in functions as their working is specified by the user and no hea 6 min read gmtime() Function in C The gmtime() function in C takes a pointer to type t_time value which represents type in seconds and converts it to struct tm. In this article, we will learn gmtime() Function in the C programming language. The struct tm type can hold the individual components of time in UTC(Universal Time Coordinat 2 min read strtof function in C Parses the C-string str(assumed) interpreting its content as a floating-point number (according to the current locale ) and returns its value as a float. If endptr(end pointer) is not a null pointer, the function also sets the value of endptr to point to the first character after the number. Syntax: 2 min read Like