#include #include #include #include #define FIFO_FILE1 "MYFIFO.1" #define FIFO_FILE2 "MYFIFO.2" int main(void) { FILE *fpr, *fpw; char readbuf[80]; int n; /* Создаем FIFO, если он еще не существует */ mkfifo(FIFO_FILE1, S_IRUSR|S_IWUSR); mkfifo(FIFO_FILE2, S_IRUSR|S_IWUSR); //fpr = fopen(FIFO_FILE1, "r"); //fpw = fopen(FIFO_FILE2, "w"); while(1) { fpr = fopen(FIFO_FILE1, "r"); //fpw = fopen(FIFO_FILE2, "w"); printf("Wait..."); //fgets(readbuf, 80, fpr); fscanf(fpr,"%s %d",readbuf,&n); fclose(fpr); n=strlen(readbuf); printf("Data: %s, len=%d\n",readbuf,n); //fprintf(fpw,"Gets %n bytes",strlen(readbuf)); //readbuf[n]='A'; //readbuf[n+1]='\n'; fpw = fopen(FIFO_FILE2, "w"); //n=fputs(readbuf,fpw); fprintf(fpw,"%d",n); printf("Sent:%d\n",n); //sleep(10); //fclose(fpr); fclose(fpw); } return(0); }