Advertisement
silver2row

Getting_Around

Feb 5th, 2022
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #define _POSIX_C_SOURCE 200809L
  2. #include <stdio.h>
  3.  
  4. int main(void)
  5. {
  6.    printf("A regular message on stdout\n");
  7.  
  8.    /* Using streams with fprintf() */
  9.    fprintf(stdout, "Also a regular message on "
  10.       "stdout\n");
  11.    fprintf(stderr, "An error message on stderr\n");
  12.  
  13.    /* Using file descriptors with dprintf().
  14.     * This requires _POSIX_C_SOURCE 200809L
  15.     * (man 3 dprintf)*/
  16.    dprintf(1, "A regular message, printed to "
  17.       "fd 1\n");
  18.    dprintf(2, "An error message, printed to "
  19.       "fd 2\n");
  20.    return 0;
  21. }
  22.  
  23. From: https://github.com/PacktPublishing/Linux-System-Programming-Techniques
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement