Browsing all articles tagged with fileno() - Share Programming Tips
Convert file descriptor to file pointer | Convert file pointer to file descriptor in Linux by C programming
If you all ready know the difference between file descriptor and file pointer then good otherwise please read this post
Whats is difference between file descriptor and file pointer?
File descriptor to file pointer :
for converting file descriptor to file pointer in linux fdopen() function is used
#include <stdio.h>
FILE *fdopen(int fildes, const char *mode);
fildes is file descriptor
mode is the character value which indicate the mode of file operation (same as we use in fopen() function)
Example :
#include <stdio .h> #include <fcntl .h> int main(){ int fd; FILE *fp; fd = open("shareprogrammingtips.txt",O_WRONLY | O_CREAT | O_TRUNC); if(fd<0) { printf("open call fail"); return -1; } fp=fdopen(fd,"w"); fprintf(fp,"we got file pointer fp bu using File descriptor fd"); fclose(fp); close(fd); return 0; } </fcntl></stdio>
Search in this website
our sponsors
latest comments
- JIGAR PATEL on List of all standard version of c language
- agabein on List of all standard version of c language
- David Wood fin on Stop Plugin from showing updates
- Alice on C programming interview questions and answers for freshers
- smitesh on How to access/unblock songs.pk in india?
Find us on Facebook
Top Authors
Find us on stackoverflow
Polls
Loading ...
My Bookmarks
- Audio/video Recorder & player application based on MATLAB
- check dependency of your binary
- defination of all standard c programming language function
- Great Question-Answer on c programming
- know what your c code means
- Limition of c programming language
- List of all version of c programming language
- Online c compiler
- php freelancing work
- some more stuff on C programming language
- Volatile Keyword in Embedded System
- Write Android application in c language