diff options
author | EliteTK <tomasz.kramkowski@gmail.com> | 2014-09-23 19:50:14 +0100 |
---|---|---|
committer | EliteTK <tomasz.kramkowski@gmail.com> | 2014-09-23 19:50:14 +0100 |
commit | 6bfc2a4830b041cd2dc93dfb932f5f56b88981da (patch) | |
tree | 291d01dc809a6c6992cb557e0f87dbef87b9ad90 /timer.c | |
parent | 0a23128c376540cd139dde19a1f09ae40617e670 (diff) | |
download | c-stuff-6bfc2a4830b041cd2dc93dfb932f5f56b88981da.tar.gz c-stuff-6bfc2a4830b041cd2dc93dfb932f5f56b88981da.tar.xz c-stuff-6bfc2a4830b041cd2dc93dfb932f5f56b88981da.zip |
Fixed .gitignore, added makefile and license, updated timer.
Diffstat (limited to 'timer.c')
-rw-r--r-- | timer.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -2,13 +2,14 @@ #include <stdlib.h> #include <string.h> #include <time.h> +#include <unistd.h> unsigned long long int get_seconds(char *); void usage(char *cmd) { printf("Usage:\n" - " %s <n>{s,m,h,D,M,Y} ...\n", cmd); + "\t%s <n>{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'; |