379_demos/lab2/demos/duplicate_fd.c
2024-09-24 13:44:04 -06:00

17 lines
275 B
C

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
int main(void) {
int fd = open("test.txt", O_CREAT | O_WRONLY);
if(fd < 0) {
printf("Error opening the file\n");
}
dup2(fd, 1);
printf("Tester\n");
close(fd);
}