/*
MYCROMARS HAWK 
C Programming Basics V1.0.5

Copyright (C) 2026 Alexander Rudi
Licensed: GNU General Public License v3.0

Source code:
https://github.com/MYCROMARS/MYCROMARS-HAWK

Contact:
https://www.mycromars.com
info@mycromars.com

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

// header file
#include "header.h"

// useful:
//#include <windows.h>

// Create 
char buffer[50];

// Catch invalid input
void scanString0(void){
    // Input
    scanf("%s", &buffer[0]);
}

// Main function
int main()
{
    // Output
    printf("\n");
    printf("MYCROMARS HAWK\n");
    printf("C Programming Basics V1.0.5\n\n");

    printf("MYCROMARS HAWK Copyright (C) 2026 Alexander Rudi\n");
    printf("This program comes with ABSOLUTELY NO WARRANTY\n");
    printf("This is free software, and you are welcome to redistribute it under certain conditions.\n");
    printf("Licensed: GNU General Public License v3.0\n");
    printf("https://www.mycromars.com\n");
    
    // Create & assign (initialize)
    int menu = 0;
    int menuB = 0;

    // Jump mark: start
    mainMenu:

    // Output
    printf("\n*** MAIN MENU ***\n");
    printf("Press (0) EXIT \n");
    printf("Press (1) CALCULATION | (2) DELAY | (3) INPUT | (4) OUTPUT\n");
    printf("Press (5) Pointer     | (6) ARRAY | (7) LOOP  | (8) STRUCTURE\n");
    printf("Press (9) MALLOC      | (10) DATA\n");

    printf("Your input: ");

    // Conditional statement
    if (scanf("%d", &menu)) {

        // Wrong number, not 1...10
        if (menu < 0 || menu > 10){
            // Output
            printf("\nInput is wrong, not 1...10\n\n");

            // Jump to start
            goto mainMenu;
        }
        // Switch-case statement
        switch (menu)
        {
            case 0:
                    /* Function: Exit */
                    mainMenu_0(&menuB);
        
            case 1:
                    /* Function: Calculation */
                    mainMenu_1(&menuB);
                    break;

            case 2:
                    /* Function: Delay */
                    mainMenu_2(&menuB);
                    break;

            case 3:
                    /* Function: Input */
                    mainMenu_3(&menuB);
                    break;

            case 4:
                    /* Function: Output */
                    mainMenu_4(&menuB);
                    break;

            case 5:
                    /* Function: Pointer */
                    mainMenu_5(&menuB);
                    break;

            case 6:
                    /* Function: Array */
                    mainMenu_6(&menuB);
                    break;

            case 7:
                    /* Function: Loop */
                    mainMenu_7(&menuB);
                    break;

            case 8:
                    /* Function: Structure */
                    mainMenu_8(&menuB);
                    break;

            case 9: 
                    /* Function: Malloc */
                    mainMenu_9(&menuB);
                    break;

            case 10:
                    /* Function: Data */
                    mainMenu_10(&menuB);
                    break;

            default:
                    // Output
                    printf("Input is not a number 1...10\n\n");
                    break;
        }
    }
    else {
        // Output
        printf("\nInput is not a number\n\n");

        // function: Catch invalid input
        scanString0();

        // Jump to start
        goto mainMenu;
    }

    // Assign (initialize)
    menu = 0;
    menuB = 0;

    // Jump to start
    goto mainMenu;
}
