create array of strings in c from user input

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

#define MAX_STRINGS 5
#define MAX_LENGTH 50

int main() {
    char strings[MAX_STRINGS][MAX_LENGTH];

    printf("Enter %d strings, each with a maximum length of %d characters:\n", MAX_STRINGS, MAX_LENGTH - 1);

    for (int i = 0; i < MAX_STRINGS; ++i) {
        printf("Enter string %d: ", i + 1);
        fgets(strings[i], MAX_LENGTH, stdin);

        // Remove the newline character at the end
        size_t len = strlen(strings[i]);
        if (len > 0 && strings[i][len - 1] == '\n') {
            strings[i][len - 1] = '\0';
        }
    }

    printf("\nYou entered the following strings:\n");
    for (int i = 0; i < MAX_STRINGS; ++i) {
        printf("String %d: %s\n", i + 1, strings[i]);
    }

    return 0;
}