diff options
Diffstat (limited to 'md/notes')
| -rw-r--r-- | md/notes/undefined_c/titles.md | 43 | 
1 files changed, 42 insertions, 1 deletions
diff --git a/md/notes/undefined_c/titles.md b/md/notes/undefined_c/titles.md index 2c5bcd1..92b35ab 100644 --- a/md/notes/undefined_c/titles.md +++ b/md/notes/undefined_c/titles.md @@ -239,10 +239,51 @@ Now size of structure will be 32.  All results on amd64, other arch may differ. +### How to shoot leg +Forget that struct size is not consistent.  +### Recursion + +Recursion is technique that could be useful to write shorter code  +and deal with cycles. One thing that recursion suffer is that it consumes +stack memory and its have default limit on platform. + +```c +#include <stdio.h> +#include <stdlib.h> + +int fun_r(int i) { +	printf("val %d\n",i); +	fun_r(i+1); +	return 0; +} + +int main()  +{ +	fun_r(0); +} +``` + +Program will fail after its reach out of stack range. +When increase the default stack limit it go more further. + + +Check default stack size + +``` +ulimit -s +``` + +Set stack size + +``` +ulimit -s 16384 +``` -### Recursion    ### Macro + + +  ### Signed/Unsigned  ### Pointers  ### Endianess   | 
