Skip to main content

Posts

Showing posts with the label IO management

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 ; }

C Program to create files with different Read/Write Permissions

  C Program to create files with different Read/Write Permissions # include <fcntl.h> # include <sys/types.h> # include <sys/stat.h> # include <stdio.h> int main ( ) { int fd , ch , q = 0 ; char name [ 25 ] ; printf ( "Enter the name of the file:" ) ; scanf ( "%s" , name ) ; fd = access ( name , F_OK ) ; if ( fd == - 1 ) { printf ( "1.User has read,write and execute permission\n" ) ; printf ( "2.User has read permission\n" ) ; printf ( "3.User has write permission\n" ) ; printf ( "4.User has execute permission\n" ) ; printf ( "5.User has read,write permission\n" ) ; printf ( "6.User has read,execute permission\n" ) ; printf ( "7.User has write,execute permission\n" ) ; printf ( "8.Group has read,write and execute permission\n" ) ; printf ( "9.Group has read permission\n" ) ; printf ( "10.Group has write per...