![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Registered User Join Date: May 2006
Posts: 181
| Understanding creation of destruction and creation of data types When an array is created where exactly is the creation taking place? In the ram? |
| yougene is offline | |
| | #2 |
| Frequently Quite Prolix Join Date: Apr 2005 Location: Canada
Posts: 7,698
| Yes, variables are created "in memory", which is almost always the RAM. Where exactly in RAM variables are created varies. "Normal" or automatic variables, for example (variables that you declare normally inside of a function), are created on the stack, and are of course destroyed when the function exits. Static and global variables are created somewhere else, in memory that is only initialized once (when the program starts) and destroyed once (when the program exits). Dynamically allocated variables (malloc()'d ones) are created on the heap, and persist until they are freed manually (by calling free()).
__________________ dwk Seek and ye shall find. quaere et invenies. "Simplicity does not precede complexity, but follows it." -- Alan Perlis "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra "The only real mistake is the one from which we learn nothing." -- John Powell Other boards: DaniWeb, TPS Unofficial Wiki FAQ: cpwiki.sf.net My website: http://dwks.theprogrammingsite.com/ Projects: codeform, xuni, atlantis, nort, etc. |
| dwks is offline | |
| | #3 |
| Registered User Join Date: May 2006
Posts: 181
| Ahh, thank you. |
| yougene is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help with basic program | JOlszewski | C Programming | 3 | 02-01-2006 04:19 PM |
| program not working...please look at this | JOlszewski | C Programming | 3 | 01-30-2006 10:33 PM |