Fifo_Creation.c
#include <stdio.h> #include <string.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> int main(){ int n,fd,fg,i; //int *p; char b[20]; mkfifo("myfifo1",0666); fd = open("myfifo1", 1); printf("Enter the string:"); scanf("%s",b); //p = &n; write(fd,(void *)&b, strlen(b)+1); close(fd); }
Fifo_access.c
#include <stdio.h> #include <string.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> int main(){ int k,fd,j,i=0; int mask = 32768; fd = open("myfifo1", 0); char a[20]; k = read(fd, (void *)&a, sizeof(a)); for(i=0, j = k-2; i < j; i++, j--){ if(a[i] == a[j]) continue; else break; } if(i>=j){ printf("Palindrome\n"); } else{ printf("Not Palindrome\n"); } close(fd); }
Post a Comment