#include <cstdio>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;


int main(int argc, char*argv[])
{
    int fd[2];
    char input;

    fd[0] = open(argv[1], O_WRONLY);
    fd[1] = open(argv[2], O_RDONLY);

    string test1 = "Rbaa";
    for (unsigned int i = 0; i < test1.size(); i++)
     {
        input = test1[i];
        string msg;
        msg +=  input;
        write(fd[0], msg.c_str(), msg.length()+1);
        char msg2[1024];
        read(fd[1], msg2, 1024);
        cout << msg2 << endl;
    }

    return 0;
}