Why would they use this segment instead of this one?
Why use this segment
Code:
#include <iostream>
using namespace std;
int main ()
{
int numbers[5];
int * p;
p = numbers; *p = 10;
p++; *p = 20;
p = &numbers[2]; *p = 30;
p = numbers + 3; *p = 40;
p = numbers; *(p+4) = 50;
for (int n=0; n<5; n++)
cout << numbers[n] << ", ";
return 0;
}
instead of this segment?
Code:
#include <iostream>
using namespace std;
int main ()
{
int a[5];
int *b;
b = a; *b = 10;
b = a; *(b+1) = 20;
b = a; *(b+2) = 30;
b = a; *(b+3) = 40;
b = a; *(b+4) = 50;
for (int n=0; n<6; n++)
cout << a[n] << ", ";
return 0;
}
Does the first, seemingly more complicated block do something more than the second block? Even though both print the same thing?
NOTE in the first block, p is equivalent to b in the second block. and "numbers" is equivalent to a.
Too much needless instructions
Simply because they are slow, and take too many lines to do something pretty simple and easy:
Code:
int main()
{
int a[5], *b = a;
for(int i = 0; i < 5;)
cout << (*(b+i) = (++i * 0xA)) << (char)0x20;
return 0;
}
Also, why not simply use a pointer from the start?
Code:
int main()
{
int *a = new int[5];
for(int i = 0; i < 5;)
cout << (*(a+i) = ((i++ + 0x14 / 0x2 + i) * 0x5) - 0x28) << (char)0x20;
return 0;
}
you could also do it using inline asm, then it would get even more ureadable, if that is your goal.
As you can see, there is a lot of ways of making something more and more unreadable. Use your criativity.