sps.c
void printErrorMessage(State err_state) {
    char *errMsgs[] = {
        [SUCCESS] = "",
        [ERR_GENERIC] = "Generic error",
        [ERR_BAD_SELECTION] = "A command can't be executed for this selection",
        [ERR_BAD_SYNTAX] = "Bad syntax",
        [ERR_COMMAND_NOT_FOUND] = "Command not found",
        [ERR_BAD_INPUT] = "Input table's format is incompatible",
        [ERR_FILE_ACCESS] = "Could not access the file",
        [ERR_MEMORY] = "Memory allocation failed",
        [ERR_INF_CYCLE] = "The program has run into an infinite loop",
    };

    const unsigned NUM_KNOWN_ERRORS = sizeof(errMsgs) / sizeof(char *);

    if (err_state < NUM_KNOWN_ERRORS) {
        fputs(errMsgs[err_state], stderr);
        fputs("\n", stderr);
        return;
    }
    fputs("Unknown error\n", stderr);
}
// prints error message according to the error state
prints error message according to the error state
prints error message according to the error state
void printErrorMessage(State err_state) {
    char *errMsgs[] = {
        [SUCCESS] = "",
        [ERR_GENERIC] = "Generic error",
        [ERR_BAD_SELECTION] = "A command can't be executed for this selection",
        [ERR_BAD_SYNTAX] = "Bad syntax",
        [ERR_COMMAND_NOT_FOUND] = "Command not found",
        [ERR_BAD_INPUT] = "Input table's format is incompatible",
        [ERR_FILE_ACCESS] = "Could not access the file",
        [ERR_MEMORY] = "Memory allocation failed",
        [ERR_INF_CYCLE] = "The program has run into an infinite loop",
    };
    const unsigned NUM_KNOWN_ERRORS = sizeof(errMsgs) / sizeof(char *);
    if (err_state < NUM_KNOWN_ERRORS) {
        fputs(errMsgs[err_state], stderr);
        fputs("\n", stderr);
        return;
    }
    fputs("Unknown error\n", stderr);
}
void printErrorMessage ( State err_state ) { char * errMsgs [ ] = { [ SUCCESS ] = " " , [ ERR_GENERIC ] = " " , [ ERR_BAD_SELECTION ] = " " , [ ERR_BAD_SYNTAX ] = " " , [ ERR_COMMAND_NOT_FOUND ] = " " , [ ERR_BAD_INPUT ] = " " , [ ERR_FILE_ACCESS ] = " " , [ ERR_MEMORY ] = " " , [ ERR_INF_CYCLE ] = " " , } ; const unsigned NUM_KNOWN_ERRORS = sizeof ( errMsgs ) / sizeof ( char * ) ; if ( err_state < NUM_KNOWN_ERRORS ) { fputs ( errMsgs [ err_state ] , stderr ) ; fputs ( " \n " , stderr ) ; return ; } fputs ( " \n " , stderr ) ; }
prints error message according to the error state
prints error message according to the error state