--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+/* Prints a time on a single line of the console.
+ * I wrote this app so that I could measure times by repeatedly pressing
+ * return.
+ *
+ * Colin McCabe
+ */
+void strip_newlines(char *str)
+{
+ size_t i;
+ size_t str_len = strlen(str);
+
+ for (i = 0; i < str_len; i++) {
+ if (str[i] == '\n')
+ str[i] = ' ';
+ }
+}
+
+int main(void)
+{
+ while (1) {
+ char str[27];
+ size_t i, len;
+ time_t t = time(NULL);
+ struct tm *tm = localtime(&t);
+
+ str[0] = '\0';
+ asctime_r(tm, str);
+ len = strlen(str);
+ printf("\r");
+ strip_newlines(str);
+ printf("%s", str);
+ fflush(stdout);
+ sleep(1);
+ }
+
+ return 0;
+}