int print_user(const User *user) {

    if (user == NULL) {
        return 1;
    }

    // char filename[MAX_NAME];
    // strncpy(filename, user->profile_pic, MAX_NAME);
    // // need to add profile pic part
    // FILE *file = fopen(filename, "r");

    // char str[60];

    // while (fgets(str, 60, file) != NULL) {
    //     printf("%s", str);
    // }
    // fclose(file);

    char filename[MAX_NAME];
    strncpy(filename, user->profile_pic, MAX_NAME);

    FILE *fp = fopen(filename, "r");
    char s[1];

    // while (fgets(s, MAX_NAME))
    fgets(s, 1, fp);
    printf("%s", s);

    fclose(fp);


    printf("Name: %s\n", user->name);

    printf("------------------------------------------\n");

    printf("Friends:\n");

    // getting all the friends
    for (int i = 0; i < MAX_FRIENDS; i++) {
        if (user->friends[i] != NULL) {
            // User *friend = user->friends[i];
            printf("%s\n", user->friends[i]->name);
        }
    }

    printf("------------------------------------------\n");

    printf("Posts:\n");

    Post *post = user->first_post;

    while (post != NULL) {

        printf("From: %s\n", post->author);
        printf("Date: %s\n", asctime(localtime(post->date)));
        printf("%s\n", post->contents);
        post = post->next;
    }
    
    if (post != NULL) {
        printf("===\n");
    }

    printf("------------------------------------------\n");

    
    return 0;
}


/*
 * Make a new post from 'author' to the 'target' user,
 * containing the given contents, IF the users are friends.
 *
 * Insert the new post at the *front* of the user's list of posts.
 *
 * 'contents' is a pointer to heap-allocated memory - you do not need
 * to allocate more memory to store the contents of the post.
 *
 * Return:
 *   - 0 on success
 *   - 1 if users exist but are not friends
 *   - 2 if either User pointer is NULL
 */
int make_post(const User *author, User *target, char *contents) {

    if (author == NULL || target == NULL) {
        return 2;
    }

    int friends = 0;
    for (int i = 0; i < MAX_FRIENDS && author->friends[i] != NULL; i++) {
        if (strcmp(author->friends[i]->name, target->name) == 0) {
            friends = 1;
            break;
        }
    }

    if (friends == 0) {
        return 1;
    }

    Post *new_post = malloc(sizeof(Post));
    if (new_post == NULL) {
        perror("malloc");
        exit(1);
    }

    strncpy(new_post->author, author->name, MAX_NAME);
    new_post->contents = contents;
    new_post->date = malloc(sizeof(time_t));
    if (new_post->date == NULL) {
        perror("malloc");
        exit(1);
    }
    time(new_post->date);

    new_post->next = target->first_post;
    target->first_post = new_post;

    return 0;
}
/*
 * Print a user profile.
 * For an example of the required output format, see the example output
 * linked from the handout.
 * Return:
 *   - 0 on success.
 *   - 1 if the user is NULL.
 */