Question: I want to perform an action based on the `Spinner`s selected value inside of the `Button`s `onClick()` method. 

How I get the selected item of a `Spinner`?

My code:

```
spinner = (Spinner) findViewById(R.id.spinner);
btnConvert = (Button) findViewById(R.id.btnConvert);
btnConvert.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
    // Here I want to perform an action based on the selected item of a listener
}

```

Answer: 
[`alloca()`](http://linux.die.net/man/3/alloca) is what you're looking for. Of course, if you know your structures dimensions statically, it'd be better to use local variables instead.
C99 also allows you to allocate variable length arrays (VLAs) and other variables at any point within a function, not just at the start, so your point about being able to allocate the memory elsewhere is moot.

You can just plug in a:

```
int arr[somevar];

```

anywhere in the function and have it actioned.

With VLAs, you no longer need to worry about using `malloc/free` (or the infamous `alloca` available on some implementations, which was another way of doing stack-based allocations, the `a` standing for `automatic`) for arbitrarily-located variable-sized allocations.

If you want the ability to resize, you're still going to have to use the standard memory allocation functions like `malloc` and `realloc`. VLAs don't provide that level of functionality (yet).