Hello Everyone,

I hope you are all doing well and thanks in advance for helping me out with the below issue.

I have the below code which is a cache memory simulation.

I am getting the following error "Write Access Violation" which seems to stem from this area of my code right where I allocate space and initialize using n* at the bottom (line 51).

Code:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>


/* define structure of dynamic cache and initialize var */
/* define dynamic array for main memory */
struct node
{


    int tag;
    int *block;//dynamic array


} *cache = NULL;


/* declare global var's */
typedef struct node n;
int *mm = NULL;
int numLines, blockSize, cacheSize;


/****************************************************************/
void enterParameters()
{
    /* declare local var's */
    /* Prompt for main memory size, cache size, block size */
    int mmSize, i;
    printf("\nEnter Parameters\n-------------------------------\n");
    printf("Enter The Size Of Main Memory (Words): ");
    scanf("%d", &mmSize);
    printf("Enter The Cache Size (Words): ");
    scanf("%d", &cacheSize);
    printf("Enter The Block Size (Blocks/Words): ");
    scanf("%d", &blockSize);


    /*allocate space for MM and initialize*/
    mm = (int*)malloc(mmSize * sizeof(int));
    
    for(i = 0; i < mmSize; i++)
    {
        mm[i] = mmSize - 1;
    }


    numLines = cacheSize/blockSize;
    
    /*allocate space for cache and initialize*/
    cache = (n*)malloc(numLines * sizeof(n));
    
    for(i = 0; i < cacheSize; i++)
    {
        cache[i].block = NULL;
    }


    return;
After staring at it and trying a few different things I cant for life of me figure out how to fix the error.

Any help would be greatly appreciated, thanks in advance.