close

PHOTO EMBED

Thu Jun 06 2024 20:43:21 GMT+0000 (Coordinated Universal Time)

Saved by @prabhas

#include<stdio.h>
#include <fcntl.h>
int main()
{
    int fd1 = open("f1.txt", O_RDONLY);
    if (fd1 = = -1)
    {
	perror("c1");
	exit(1);
    }
    printf("opened the fd = % d\n", fd1);

    // Using close system Call
    if (close(fd1) = = -1)
    {
	perror("c1");
	exit(1);
    }
    printf("closed the fd.\n");
    return 0;
}
content_copyCOPY