Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Practice InterviewNew Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

Language in C Interview Questions and Answers

Ques. How do I write code to retrieve current date and time from the system and display it as a string?

Ans. Use time( ) function to get current date and time and then ctime( ) function to display it as a string. This is shown in following code snippet.

#include <sys\types.h>

void main( )
time_t curtime ;
char ctm[50] ;

time ( &curtime ) ; //retrieves current time &
stores in curtime
printf ( "\nCurrent Date & Time: %s", ctime (
&curtime ) ) ;

Is it helpful? Yes No

Most helpful rated by users:

©2020 WithoutBook