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.

Your program should use the exit status of the validate program to determine which of the three following messages to print.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

#define MAXLINE 256

#define SUCCESS "Password verified\n"
#define INVALID "Invalid password\n"
#define NO_USER "No such user\n"

int main(void) {
  char user_id[MAXLINE];
  char password[MAXLINE];

  /* 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);
  }

  user_id[strcspn(user_id, "\n")] = '\0';
  password[strcspn(password, "\n")] = '\0';
  
  // fork process
  pid_t n = fork();
  if (n < 0){
    perror("fork");
    exit(1);
  }

  if (n == 0) {
    // child process replace with validate program
    int a = execl("./validate", "validate", NULL);
    if (a == -1){
      perror("execl");
      exit(1);
    }
    write(STDIN_FILENO, user_id, strlen(user_id) + 1);
    write(STDIN_FILENO, password, strlen(password)+1);
    exit(a);
  } else if (n>0) {
    // parent process
    int status;
    pid_t child_pid = wait(&status);
    if (child_pid == -1){
      perror("wait");
      exit(1);
    }
    if (WIFEXITED(status)){
      int exit_status = WEXITSTATUS(status);
      if (exit_status == 0){
        printf(SUCCESS);
      } else if (exit_status == 2){
        printf(INVALID);
      } else if (exit_status == 3){
        printf(NO_USER);
      }
    }
  }

  return 0;
}
