X-Git-Url: https://git.piment-noir.org/?p=TD_IML.git;a=blobdiff_plain;f=TD2%2Fexercise1%2Fexercise.c;fp=TD2%2Fexercise1%2Fexercise.c;h=8b112a7776093adf524c9f2ff2186ee9bddfa8d5;hp=0000000000000000000000000000000000000000;hb=d57668faea3e58be64bb9fbe8cde3c293ebb7990;hpb=720c45c786b902933b74162b1b05b04ab0be97a2 diff --git a/TD2/exercise1/exercise.c b/TD2/exercise1/exercise.c new file mode 100644 index 0000000..8b112a7 --- /dev/null +++ b/TD2/exercise1/exercise.c @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +#include +#include + +int main() { + int out_file_fd = open("ouput.txt", O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR); + if (out_file_fd < 0) { + perror("open failure\n"); + exit(EXIT_FAILURE); + } + + dup2(out_file_fd, STDOUT_FILENO); + + puts("Redirection de stdout du processus dans ce fichier"); + + close(out_file_fd); + + return EXIT_SUCCESS; +}