A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
17
Task/Memory-allocation/C/memory-allocation-2.c
Normal file
17
Task/Memory-allocation/C/memory-allocation-2.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
int func()
|
||||
{
|
||||
int ints[NMEMB]; /* it resembles malloc ... */
|
||||
int *int2; /* here the only thing allocated on the stack is a pointer */
|
||||
char intstack[SIZEOF_MEMB*NMEMB]; /* to show resemblance to malloc */
|
||||
int2 = (int *)intstack; /* but this is educative, do not do so unless... */
|
||||
|
||||
{
|
||||
const char *pointers_to_char[NMEMB];
|
||||
/* use pointers_to_char */
|
||||
pointers_to_char[0] = "educative";
|
||||
} /* outside the block, the variable "disappears" */
|
||||
|
||||
/* here we can use ints, int2, intstack vars, which are not seen elsewhere of course */
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue