From 6bfc2a4830b041cd2dc93dfb932f5f56b88981da Mon Sep 17 00:00:00 2001 From: EliteTK Date: Tue, 23 Sep 2014 19:50:14 +0100 Subject: Fixed .gitignore, added makefile and license, updated timer. --- timer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'timer.c') diff --git a/timer.c b/timer.c index 153bcb8..532a5ed 100644 --- a/timer.c +++ b/timer.c @@ -2,13 +2,14 @@ #include #include #include +#include unsigned long long int get_seconds(char *); void usage(char *cmd) { printf("Usage:\n" - " %s {s,m,h,D,M,Y} ...\n", cmd); + "\t%s {s,m,h,D,M,Y} ...\n", cmd); } int main(int argc, char **argv) @@ -21,8 +22,7 @@ int main(int argc, char **argv) unsigned long long int total_seconds = 0; - int i; - for (i = 1; i < argc; i++) + for (int i = 1; i < argc; i++) total_seconds += get_seconds(argv[i]); printf("Total time: %llu second(s).\nStarted at: %d\n", total_seconds, time(NULL)); @@ -59,7 +59,7 @@ unsigned long long int get_seconds(char *code) } char value[length + 1]; - strcpy(value, code); + strncpy(value, code, length + 1); value[length - 1] = '\0'; -- cgit v1.2.3-54-g00ecf