A
anish singh
So here is the problem:
Progarm 'A'
main()
{
char array[128] = {0};
memcpy(array, "testing", strlen("testing"));
}
Progarm 'B'
main()
{
char array[128];
memcpy(array, "testing", strlen("testing"));
array[strlen("testing")] = '\0';
}
Which one is better program?Definition of better: A program is better if it has less code size and executes in less cycle.
Argument 1: Program 'B' is better as it doesn't have to initialize the whole array and just need to append '\0' at the end which is just one more cycle.
Please answer this question with concrete data in any architecture i.e. ARM, x86 or anything which is available to you.
Please use disassembly to explain your point w.r.t. cycles or code size.Strictly guess is not allowed.
Progarm 'A'
main()
{
char array[128] = {0};
memcpy(array, "testing", strlen("testing"));
}
Progarm 'B'
main()
{
char array[128];
memcpy(array, "testing", strlen("testing"));
array[strlen("testing")] = '\0';
}
Which one is better program?Definition of better: A program is better if it has less code size and executes in less cycle.
Argument 1: Program 'B' is better as it doesn't have to initialize the whole array and just need to append '\0' at the end which is just one more cycle.
Please answer this question with concrete data in any architecture i.e. ARM, x86 or anything which is available to you.
Please use disassembly to explain your point w.r.t. cycles or code size.Strictly guess is not allowed.