Implemented a program in c for fifo..pls help

I have implemented below program in c.
While debugging its giving error on Open, Read commands as "identifier "open" not defined" and
Error 5 error LNK2019: unresolved external symbol _mkfifo referenced in function _main
Error 6 error LNK1120: 1 unresolved externals
Please help asap.. 😔
#include
#include
#include
#include
#include
#define FIFO "/root/test/test"

int    mkfifo( char *,int mode_t);

int main(int argc, char** argv)
{
    char buf_r[100];
    int fd;
    int nread;
    if((mkfifo(FIFO, O_CREAT) < 0) && (errno != EEXIST))
    {
            printf("can not create FIFO\n");
            exit(1);
    }

    printf("Prepare read data\n");
    fd = Open(FIFO, O_RDONLY);
    if(fd == -1)
    {
            exit(1);
    }

    while(1)
    {
            if((nread = Read(fd, buf_r, 100)) == -1)
            {
                    if(errno == EAGAIN) printf("No data\n");
            }

            if(buf_r[0]=='Q') break;

            buf_r[nread]=0;
            printf("data is:%s\n", buf_r);
            Sleep(1);
    }

} 

Replies

  • Vishal Sharma
    Vishal Sharma
    I think this program is supposed to be executed in unix box not on windows. I strongly feel that you are using windows (Just saw the headers, haven't gone through the program yet)

    Update
    Yup, it should be executed in unix box. I'll let you try this code in linux and get back with the results

You are reading an archived discussion.

Related Posts

Austrian software engineer Philipp Sonnleitner has taken the initiative to shake up the portable audio recording devices market with a revolutionary product that promises truly wireless recording of studio-quality audio....
i would be helpful if u post what type of question were asked section A+B
why we do partial moment release in designing structure .. what is theory behind it . we can do it or not in designing structure ... please help ...
Guyz... .plz suggest me some good projects... I m student of the E & TC engg. last year. -Thank you
The Chinese 'flagship killer' company, OnePlus has revealed that the upcoming OnePlus 2 phone will sport a USB Type C (Read: USB Type C Explained) port for charging and connectivity....