c - Do function parameters take up local memory space? -


in following example, taking local memory space in function "add"? , if not, parameter variables stored in memory?

void add(int *a, int *b, int *result){    *result = *a + *b;  }   int main(){    int = 1, b = 2, result;    add(&a, &b, &result);    printf("result = %d\n", result);  return 0;  }  

do function parameters take local memory space?

in following example, taking local memory space in function "add"?

the answer these questions depends heavily upon implementation. perhaps implementation automatically inlines functions, , function parameters might eliminated entirely inlining process. implementation might hoist of runtime logic compile time; i.e. entire example can optimised puts("result = 2"); during compilation.

alternatively...

where parameter variables stored in memory?

often times, arguments stored register storage. register storage committed program, , might otherwise committed , unused; it'd waste not use purpose.

suffice say, c doesn't require register storage exist, , shouldn't relied upon. @ end of day, you shouldn't care variables stored; should matter they stored.

stack, heap, register... cares? it's same place, in same computer, right? time makes difference when you're optimising, , sake of avoiding premature optimisation should ask question at time of optimisation, , scope appropriate optimisation.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -