Message from C, C++ talks

July 2019

— It could be a right solution, I went into hypnosis 🙂
I'll check!

— I'll let you know soon..

— Yes please

— That is right solution))


Why is the j value 2 here? shouldn't it be 1? coz a[1] is 1 there and given statement is the post shouldn't the j value stay as 1?

— It is incremented when you do i=++a[1];

— I = ++a[1]; // i = 2, a[1] = 2 now

— Yeah i=2,but why does it effect a[1]? i is just a variable right? why would assigning a variable effect array element?

Message permanent page

— Another one bites the dust...!
Banned Dan.
Cryptocurrency ad

— Array is just a pointer, so when u increment arr[index] u increment array element, not it's copy

— Try to declare

const int arr[5] ... 

instead of
int arr[5] ...

for better understanding

— Okay... one more try

int arr[2] = {1, 2};
// u create actually a pointer (int *) named arr, it
//points to a
//memory-area with size sizeof(int) * 2;
int i = ++arr[0];
// here u just write this actually: int i = ++*(arr + 0);
// so u increment variable, that locate at 'arr + 0' address

Message permanent page

— Well thanks! that explains 😁

— Another one bites the dust...!

— Hi, i'm newbie