Horje
fifo in c Code Example
fifo in c
// C program to implement one side of FIFO
// This side writes first, then reads
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
    int fd;

    // FIFO file path
    char * myfifo = "/tmp/myfifo";

    // Creating the named file(FIFO)
    // mkfifo(<pathname>, <permission>)
    mkfifo(myfifo, 0666);

    char arr1[80], arr2[80];
    while (1)
    {
        // Open FIFO for write only
        fd = open(myfifo, O_WRONLY);

        // Take an input arr2ing from user.
        // 80 is maximum length
        fgets(arr2, 80, stdin);

        // Write the input arr2ing on FIFO
        // and close it
        write(fd, arr2, strlen(arr2)+1);
        close(fd);

        // Open FIFO for Read only
        fd = open(myfifo, O_RDONLY);

        // Read from FIFO
        read(fd, arr1, sizeof(arr1));

        // Print the read message
        printf("User2: %s\n", arr1);
        close(fd);
    }
    return 0;
}




C

Related
Parsing using strtok Code Example Parsing using strtok Code Example
are two matrcies identical Code Example are two matrcies identical Code Example
north austin weather Code Example north austin weather Code Example
javascript Code Example javascript Code Example
KeyError: "['Adult Mortality' 'infant deaths' 'Alcohol' 'percentage expenditure'] not found in axis" site:stackoverflow.com Code Example KeyError: "['Adult Mortality' 'infant deaths' 'Alcohol' 'percentage expenditure'] not found in axis" site:stackoverflow.com Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7