I update my code. I need help with the character array. I'm not sure if I doing it right but im trying to get the program to ask the user to add a value to the character that is being displayed.
Code:
#include <unistd.h>
#include <sys/types.h>
int main()
{
int fd[2];
int nbytes;
pid_t childpid;
char garbage[30];
int m;
pipe(fd);
if((childpid = fork()) == -1)
{
perror("fork");
exit(1);
}
else if(childpid == 0)
{
//Child process 1
dup2(fd[0], 0);
read(fd[0], garbage, sizeof garbage);
while (printf("Character: %d", garbage[]), fgets(garbage, 30, stdin), !feof(stdin)){
if
}
else if(childpid > 0)
{
//Parent
read(fd[#], "input.txt", "rb");
write(fd[#], garbage, sizeof garbage);
childpid = fork();
if(childpid == -1){
perror("fork");
exit(1);
}
else if (childpid == 0)
{
//Child process 2
close(fd[0]);
dup2(fd[1], 1);
}
return 0;