Program below have to return pointer to an array of names taken from names[] if \*pMonthToStudy parameter of Exam function equals birth month of coressponding person (birthDates[] order corresponds to names[] order). In case of June, function should return "John, James, Richard". The output must have exactly the same view as my example.

**Do I allocate memory correct?
If yes, how to assign those values to returning pointer and output it correctly in main (if my output method is incorrect)?**

```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
    int day;
    char month[4];
    int year;
} DATE;

DATE birthDates[] = {{2, "Jun", 2000}, {27, "Jul", 2001}, {12, "Jun", 1999},
                     {15, "Sep", 1998}, {16, "Jun", 2000}};

char names[] = {"John, Mary, James, Elizabeth, Richard"};

char *Exam(char *pNames, DATE *pBirthDates, const char *pMonthToStudy){
    //Check if input ptr are zero or point to empty strings
    if(!pNames || !*pNames || !pBirthDates)
        return 0;
    char *pOutput = (char*) malloc(sizeof(*pNames));
    for (int i = 0; i < 5; ++i) {
        if(strcmp(pMonthToStudy, &birthDates->month[i]) == 0){
            strcpy(pOutput, &pNames[i]);
        } else
            return 0;
    }
    return pOutput;
}
int main() {
    char *pResult = Exam(names, birthDates, "Jun");
    printf("%s", pResult);
    return 0;
}

```