char* print_user(const User* user) {
    if (user == NULL) {
        return NULL;
    }

    int length = 0;

    length += snprintf(NULL, 0, "Name: %s\r\n\r\n", user->name);
    if (length < 0) {
        perror("snprintf");
        exit(1);
    }
    char* output = malloc(length + 1);
    if (output == NULL) {
        perror("malloc");
        exit(1);
    }

    length = strlen(output);

    length += snprintf(output + length, strlen("Friends:\r\n") + 1, "Friends:\r\n");
    for (int i = 0; i < MAX_FRIENDS && user->friends[i] != NULL; i++) {
        length += snprintf(output + length, strlen(user->friends[i]->name) + strlen("\r\n") + 1, "%s\r\n", user->friends[i]->name);
    }
    length += snprintf(output + length, strlen("------------------------------------------\r\n") + 1, "------------------------------------------\r\n");

    length += snprintf(output + length, strlen("Posts:\r\n") + 1, "Posts:\r\n");
    const Post* curr = user->first_post;
    while (curr != NULL) {
        char* post_output = print_post(curr);
        if (post_output != NULL) {
            length += snprintf(output + length, strlen(post_output) + 1, "%s", post_output);
            free(post_output);
        }
        curr = curr->next;
        if (curr != NULL) {
            length += snprintf(output + length, strlen("\r\n===\r\n\r\n") + 1, "\r\n===\r\n\r\n");
        }
    }
    length += snprintf(output + length, strlen("------------------------------------------\r\n") + 1, "------------------------------------------\r\n");

    return output;
}