From cc194dc4eee1fe0e64a924ad3e6c0b88fca901b8 Mon Sep 17 00:00:00 2001 From: KRZYSZTOF RUDNICKI Date: Tue, 23 Jul 2024 14:02:48 +0200 Subject: [PATCH] feat: initialize srand at the very beginning of program: --- C/misc/randomJPG/generate_jpg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C/misc/randomJPG/generate_jpg.c b/C/misc/randomJPG/generate_jpg.c index 66ac7bd..d9a0e35 100644 --- a/C/misc/randomJPG/generate_jpg.c +++ b/C/misc/randomJPG/generate_jpg.c @@ -47,7 +47,6 @@ unsigned char* allocate_image_buffer(int size) { } void fill_image_with_colors(unsigned char* image_buffer, int size, RGB* color_list, int num_colors, int block_size) { - srand(time(NULL)); for (int y = 0; y < size; y += block_size) { for (int x = 0; x < size; x += block_size) { RGB color = color_list[rand() % num_colors]; @@ -206,6 +205,7 @@ int handle_help_option(int argc, char *argv[]) { } int main(int argc, char *argv[]) { + srand(time(NULL)); if (handle_help_option(argc, argv)) { return EXIT_SUCCESS; }