#include<unistd.h>
#include<stdio.h>
#include<string.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<stdlib.h>
int main()
{
    int fd1;
    char  * myfifo = "/home/karthik/code/test.txt";
    mkfifo(myfifo, 0666);
    char str1[80],str2[80],Conformation_Flag;
    //Shows what's in file.
    fd1 = open(myfifo,O_RDONLY);
    read(fd1,str1,80);
    printf("Text : %s",str1);
    close(fd1);
    printf("Edit? (y/n) : ");
    scanf("%c",&Conformation_Flag);
    
    if(Conformation_Flag == 'y')
    {   
        printf("Enter the text : ");
        fflush(stdin);
        //Take input and write to file.
        fd1 = open(myfifo,O_WRONLY);
        
        fgets(str2,80,stdin);
        
        write(fd1,str2 ,strlen(str2)+1);
        
        close(fd1);
    }
    else if(Conformation_Flag == 'n')
    {
        exit(0);
    }
    else
    {
        printf("Invalid Option!");
    }
             
return 0;
}
I'm expecting output like this :
Text : Dummpy text
Edit? (y/n) : y
Enter the Text : Again Dummy text
After Pressing enter Program should be exit.
But i'm getting output like this :
Text : Dummpy text
Edit? (y/n) : y
program exiting without taking input.
Compiling on wsl(Debian 10) and gcc (Debian 8.3.0-6) 8.3.0
And tried giving space at "%c "[ scanf("%c ",&Conformation_Flag); ] But it's not closing after taking input
 
     
    