1. Takayuki KONDO
  2. playground

Commits

Takayuki KONDO  committed a9a6ff9

c: time関数 サンプルコード追加

  • Participants
  • Parent commits 979a350
  • Branches default

Comments (0)

Files changed (1)

File c/time.c

View file
+#include <stdio.h>
+#include <time.h>
+
+#define TIME_MAXSIZE 64
+
+void nowtime(char *str)
+{
+    time_t timer = time(NULL);
+    strftime(str, TIME_MAXSIZE, "[%Y/%m/%d %H:%M:%S]", localtime(&timer));
+}
+
+int main()
+{
+	char timestr[TIME_MAXSIZE];
+	
+	nowtime(timestr);
+	printf("%s\n", timestr);
+
+	return 0;
+}