How to use the ctime() function in C

1 Answer

0 votes
#include <stdio.h>
#include <time.h>

// char *ctime(const time_t *timer) // get localtime

int main() {
	time_t curtime;

	time(&curtime);

	printf("%s", ctime(&curtime));

	return 0;
}




/*
run:

Sun Jan  8 09:53:10 2023

*/

 



answered Jan 8, 2023 by avibootz
...