...
This non-compliant code example can fail because a copy of stdout is being used in the call to fputs().
| Code Block | ||
|---|---|---|
| ||
#include <stdio.h>
int main(void) {
FILE my_stdout = *(stdout);
fputs("Hello, World!\n", &my_stdout);
return 0;
}
|
...
In this compliant solution, a copy of the pointer to the FILE object is used in the call to fputs().
| Code Block | ||
|---|---|---|
| ||
#include <stdio.h>
int main(void) {
FILE *my_stdout = stdout;
fputs("Hello, World!\n", my_stdout);
return 0;
}
|
...