Embed Notice
HTML Code
Corresponding Notice
- Embed this notice
翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Friday, 24-Nov-2023 22:46:00 JST翠星石 @kirby Okay, here you go;
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
int main()
{
/* open file */
int fp = open("main.c", O_RDONLY);
/* get file stats */
struct stat s;
fstat(fp, &s);
char buffer[s.st_size];
ssize_t ignored = read(fp, buffer, s.st_size);
close(fp);
ignored = write(STDOUT_FILENO, buffer, sizeof(buffer));
}