C Program to show an example of I/O Management


 

C Program to show an example of I/O Management
#include<unistd.h>
#include<fcntl.h>
#include<string.h>
#include<stdio.h>
int main()
{
        int fd;
        char buf1[25];
        fd=open("tfile.txt",O_RDWR|O_CREAT);
        printf("\nEnter your text now:");
        gets(buf1);
        write(fd,buf1,strlen(buf1));
        read(fd,buf1,sizeof(buf1));
        printf("\"%s\"was written to tfile.txt\n",buf1);
        close(fd);
        printf("\n");
        return 0;
}

Post a Comment

Previous Post Next Post