improved random seed to be less predictable
This commit is contained in:
22
.github/workflows/create_package_on_release.yml
vendored
Normal file
22
.github/workflows/create_package_on_release.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: create package on release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
build_package_and_release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: create deb package
|
||||
run: dpkg-deb --build ./package
|
||||
|
||||
- name: upload release assets
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{github.event.release.tag_name}}
|
||||
files: "${{github.workspace}}/builds/*"
|
||||
|
||||
18
src/main.c
18
src/main.c
@@ -1,18 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main(void) {
|
||||
srand(time(NULL)); // set the random seed to the system time
|
||||
char* result = NULL;
|
||||
|
||||
if (rand() & (~1) != 0) {
|
||||
result = "heads";
|
||||
}
|
||||
else {
|
||||
result = "tails";
|
||||
}
|
||||
|
||||
printf("%s\n", result);
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
srand((uint32_t)(ts.tv_nsec ^ ts.tv_sec)); // combine seconds and nanoseconds
|
||||
printf("%s\n", (rand() & 1) ? "heads" : "tails");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user