#include<iostream>
#include<unistd.h>
#include<fcntl.h>
#include<sys/types.h>
#include<sys/stat.h>
using namespace std;
int main(){
    int n, fd;
    char buff[50];
    
    cout<<"Enter text to write in the file: "<<endl;
    
    n=read(0, buff, sizeof(buff));
    fd = open("A.txt", O_CREAT | O_RWDR, 0777);
    if(fd < 0){
        perror("File open error");
        return 1;
    }
    write(fd, buff, n);
    write(1, buff, n);
    close(fd);
    
    return 0;
}