#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>

int main() {
    int fd;
    unsigned int seed;
    // 打开/dev/urandom设备文件
    fd = open("/dev/urandom", O_RDONLY);
    if (fd == -1) {
        perror("无法打开/dev/urandom");
        return 1;
    }
    // 从设备文件中读取4个字节作为种子
    if (read(fd, &seed, sizeof(seed))!= sizeof(seed)) {
        perror("无法读取随机种子");
        close(fd);
        return 1;
    }
    close(fd);
    srand(seed);
    // 这里可以继续进行猜数字游戏的其他部分，例如生成随机数并开始游戏
    int number_to_guess = rand() % 100 + 1;
    //...（省略猜数字游戏的其他代码）
    return 0;
}
