Skip to content

Instantly share code, notes, and snippets.

@geekoff7
Created August 1, 2018 06:56
Show Gist options
  • Save geekoff7/4e064f03172677603649c8947266de8b to your computer and use it in GitHub Desktop.
Save geekoff7/4e064f03172677603649c8947266de8b to your computer and use it in GitHub Desktop.
file pointer and file descriptor in c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char const *argv[])
{
char str[] = "Hello World !!!";
int fd = fileno(stdout);
FILE *fp = fdopen(fd, "w");
fwrite(str, sizeof(char), sizeof(str), fp);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment