Preview:
#include <sys/ipc.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <sys/stat.h> // Include this header for mkfifo

int main()
{
    int fd[2], i, j, x, k;
    pid_t pid;
    char string[] = "hello";
    char b[80];

    i = mkfifo("f1.txt", 0666);
    
    pid = fork();
    
if (pid == 0)
    {
        j = open("f1.txt",O_RDWR);
        
        write(j, string, strlen(string));
        close(j);
    }
    else 
    {
        k = open("f1.txt", O_RDONLY);
       
        x = read(k, b, sizeof(b));
       
        printf("Received String: %s\n", b);
        close(k);
    }

    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter