If we define an array inside `SomeFunction` it is valid in its scope. But where is it stored actually? Local variables are usually stored on the stack but I was asking myself if the whole array stored on the stack or just the pointer to the datafield, where the data is actually stored (like calling malloc which allocates memory on the heap). Talking about the implementation in microcontrollers.

So this question leads me also to another question. If the data is stored in the Heap, is it a valid operation if the pointer will be saved to `pdata`and accessed in a different scope (`SomeOtherFunction`)? Is the data valid to use there or how do I know if the data is not valid anymore?

```
#define DATAFIELDLEN 127

static uint8_t* pdata;

static void SomeFunction()
{
    uint8_t dataField[DATAFIELDLEN] = {};

    // Write some stuff to the datafield

    pdata = dataField;  // Save pointer to the datafield
}

static void SomeOtherFunction()
{
    // Use datafield here
    for(uint8_t ii=0; ii<DATAFIELDLEN; ii++){
        // Dereference Data here
        someOperation(pdata[ii]);       // <-------- is the data valid here?
    }
}

void main() 
{
    SomeFunction();
    SomeOtherFunction();
}

```

Another possibility would be to to define the datafield in the global scope of this file as `static`. Then the data is stored in the zero initialized data and is valid in the whole file. But in the approach I presented I thought of saving some space in the RAM by not holding this datafield available all the time. Or is there another usefull practice?