int main(int argc, char **argv) {
    // Declare any variables you need
    int fd[argc][2];
    int one_value;

    // Write the code to loop over the command line arguments
    for (int i = 1; i < argc; i++) {
        // Call pipe before we fork
        if (pipe(fd[i]) == -1) {
            perror("pipe");
            exit(1);
        }
        // Call fork
        int result = fork();
        if (result < 0) {
            perror("fork");
            exit(1);
        } else if (result == 0) {
            // Child only writes to the pipe, so close reading end
            Close(fd[i][0]);
            // Before we forked, parent had open the reading ends to
            // all previously forked children; so close those.
            for (int j = 1; j < i; j++) {
                Close(fd[j][0]);
            }
            // Now do the work - write the value in binary to the pipe
            int length = strlen(argv[i]);
            write(fd[i][1], &length, sizeof(int));
            // Close the pipe since we are done with it.
            Close(fd[i][1]);
            exit(0);
        } else {
            // In the parent, but before doing the next loop iteration,
            // close the end of the pipe that we don't want open
            Close(fd[i][1]);
        }
    }
    // Only the parent gets here
    int sum = 0;

    for (int i = 1; i < argc; i++) {
        // Read one integer from each child
        read(fd[i][0], &one_value, sizeof(int));
        printf("I just read %d from pipe %d\n", one_value, i);

        sum += one_value;
    }

    printf("Sum is %d\n", sum);
    return 0;
}