Question: I am having trouble with the Jquery scrollto command on iphone and ipads, it keeps flickering every time its used and gets stuck so I have decided to remove the code for these devices but am having trouble doing so. Here is the code I am trying to use to only show the javascript on a decktop browser.

```
<script type="text/javascript"> // <![CDATA[
if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {
    document.write = "<meta name=\"viewport\" content=width=1024px, minimum-scale=1.0, maximum-scale=1.0 \/>";
}
else{document.write = "<script type=\"text/javascript\">
$(document).ready(function() {$('.nav').onePageNav({begin: function() {console.log('start');}, end: function() {console.log('stop');}, scrollOffset: 30});});
</script>";} // ]]>
</script>

```

The dev site can be found here: dev.greendealcumbria.com

Cheers

Answer: 
* The first one puts the array on the stack.
* The second one allocates it on the heap.

In the first case, the lifetime of the array is only the scope at which it is defined in. 
When it falls out of scope, it will be freed automatically so you don't have to do any clean up.

In the second case, the array lives beyond the scope where the pointer is declared. So you will need to manually `free()` it later to avoid a memory leak.
The first is allocated on the stack.

* Its lifetime is the surrounding scope, and you don't have to manually deallocate the memory it occupies since it will be deallocated when the enclosing scope ends (it is said to have an **automatic** storage duration)
* Compile-time arrays like this must have a constant size (that is, the size must be known at compile time, not runtime. Unless you are using C99 which allows Variable Length Arrays (VLAs) or the GCC compiler which has a non-standard extension to allow that
* Once they are created, they cannot be resized

The second is allocated on the heap.

* Its lifetime is until you manually deallocate it with `free` (it is said to have **dynamic** storage duration)
* If you don't use `free` on it before you lose all pointers to it (in this case, before the pointer to it goes out of scope), you will have a [memory leak](http://en.wikipedia.org/wiki/Memory_leak)
* The size of these arrays can be determined at runtime
* You can use `realloc` on the pointer to the array to ask the C runtime to try to make it bigger (or smaller) in place (or move it to a different larger area of memory if resizing it in place is not possible)