CS631 -- Advanced Programming in the UNIX Environment

File Descriptors and Stdout Exercise

Write a program to prove that the following logic is flawed:

#define MSG "This message goes to stdout.\n"
if (fd == STDOUT_FILENO) {
        write(fd, MSG, strlen(MSG));
} 

As always, remember to always write "production quality" code.


[Course Website]