S
sam_cit
Hi Everyone,
I have the following structure and i have a function that will
work(modify/edit) the members of the structure, please tell me which is
a better apprach considering both time and memory complexity,
struct sample
{
char* string;
int n;
}*p;
(a0 func(struct sample*p)
{
char * local_string = p->string;
int local_n = p->n;
...
}
// This will have three variables on the stack
(b) func(char *local_string,int local_n)
{
...
}
//This will have two variables on the stack
I feel first approach was good, but looking at one increased member in
stack, i'm wondering... also note that i'm storing the members of the
structure into a local variable because in real project the structure
name and pointer are lengthy and doesn't help in readability of the
code. Please let me know your suggestions...
I have the following structure and i have a function that will
work(modify/edit) the members of the structure, please tell me which is
a better apprach considering both time and memory complexity,
struct sample
{
char* string;
int n;
}*p;
(a0 func(struct sample*p)
{
char * local_string = p->string;
int local_n = p->n;
...
}
// This will have three variables on the stack
(b) func(char *local_string,int local_n)
{
...
}
//This will have two variables on the stack
I feel first approach was good, but looking at one increased member in
stack, i'm wondering... also note that i'm storing the members of the
structure into a local variable because in real project the structure
name and pointer are lengthy and doesn't help in readability of the
code. Please let me know your suggestions...