diff --git a/random.c b/random.c index 8deb622..e245c78 100644 --- a/random.c +++ b/random.c @@ -1,17 +1,23 @@ #include #include +#include + int random_int(int max) { -return rand() % max; + return rand() % max; } + int main(int argc, char *argv[]) { -if (argc != 2) { -fprintf(stderr, "Usage: %s \n", argv[0]); -return EXIT_FAILURE; -} -int max = atoi(argv[1]); -int result = random_int(max); -printf("%d\n", result); -return EXIT_SUCCESS; + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return EXIT_FAILURE; + } + int max = atoi(argv[1]); + + srand(time(NULL)); + int result = random_int(max); + printf("%d\n", result); + + return EXIT_SUCCESS; }