checkpasswd.c reads a user id and password from stdin, creates a new process to run the validate program, sends it the user id and password, and prints a message to stdout reporting whether the validation is successful.
int main(void) {
  char user_id[MAXLINE];
  char password[MAXLINE];
  int status;

  /* The user will type in a user name on one line followed by a password 
     on the next.
     DO NOT add any prompts.  The only output of this program will be one 
	 of the messages defined above.
     Please read the comments in validate carefully
   */

  if(fgets(user_id, MAXLINE, stdin) == NULL) {
      perror("fgets");
      exit(1);
  }
  if(fgets(password, MAXLINE, stdin) == NULL) {
      perror("fgets");
      exit(1);
  }
  
  // TODO
  if (strlen(user_id) > (MAX_PASSWORD + 1)) {
    printf("%s",NO_USER);
    exit(0);
  }
  
  if (strlen(password) > (MAX_PASSWORD + 1)) {
    printf(INVALID);
    exit(0);
  }

  int pipefd[2];
  pipe(pipefd);

  int result = fork();
  if (result < 0) {
    perror("fork");
    exit(1);
  }
  else if (result == 0) {
    dup2(pipefd[0], STDIN_FILENO);
    dup2(pipefd[1], STDOUT_FILENO);
    close(pipefd[0]);
    close(pipefd[1]);

    execl("./validate", "validate", NULL);
  
  } else {
    close(pipefd[0]);
    write(pipefd[1], user_id, MAX_PASSWORD);
    write(pipefd[1], password, MAX_PASSWORD);
    close(pipefd[1]);

    pid_t child_pid = wait(&status);
    if (child_pid < 0) {
      perror("wait");
      exit(1);
    }

    if (WIFEXITED(status)) {
      if (WEXITSTATUS(status) == 0) {
        printf("%s", SUCCESS);
      } else if (WEXITSTATUS(status) == 2) {
        printf("%s", INVALID);
      } else if (WEXITSTATUS(status) == 3) {
        printf("%s", NO_USER);
      }
      
    }

  }
  return 0;
}