Some indentation cleanups on the Mastermind game
[TD_IML.git] / TD2 / exercise2 / exercise.c
... / ...
CommitLineData
1#include <stdlib.h>
2#include <stdio.h>
3#include <fcntl.h>
4#include <unistd.h>
5
6#include <sys/types.h>
7#include <sys/stat.h>
8
9int main() {
10 int out_file_fd = open("ouput.txt", O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
11 if (out_file_fd < 0) {
12 perror("open failure\n");
13 exit(EXIT_FAILURE);
14 }
15
16 dup2(out_file_fd, STDOUT_FILENO);
17
18 execl("/bin/ls", "ls", (char*)NULL);
19
20 close(out_file_fd);
21
22 return EXIT_SUCCESS;
23}