gigaseconds (C)
This commit is contained in:
26
c/gigasecond/src/gigasecond.c
Normal file
26
c/gigasecond/src/gigasecond.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "gigasecond.h"
|
||||
|
||||
/* See GNUmakefile in following link for explanation
|
||||
* https://exercism.io/my/solutions/103b2f7d92db42309c1988030f5202c7
|
||||
*/
|
||||
#if defined UNIT_TEST || defined DEBUG
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
time_t gigasecond_after(time_t t)
|
||||
{
|
||||
return t+1e9;
|
||||
}
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
int arg=1;
|
||||
unsigned long i;
|
||||
for (; arg<ac-1; ++arg) {
|
||||
i=atol(av[arg]);
|
||||
printf("giga(%lu)=%lu\n", i, gigasecond_after(i));
|
||||
}
|
||||
}
|
||||
#endif
|
16
c/gigasecond/src/gigasecond.h
Normal file
16
c/gigasecond/src/gigasecond.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef GIGASECOND_H
|
||||
#define GIGASECOND_H
|
||||
|
||||
#include <time.h>
|
||||
|
||||
time_t gigasecond_after(time_t);
|
||||
|
||||
/* See GNUmakefile in following link for explanation
|
||||
* https://exercism.io/my/solutions/103b2f7d92db42309c1988030f5202c7
|
||||
*/
|
||||
#ifdef TESTALL
|
||||
#undef TEST_IGNORE
|
||||
#define TEST_IGNORE() {}
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user