spadez

05-10-2009, 06:48 PM

Hi,

Ive been given this code:

int i=0, j=0, *k=0, *l=0;

k = l;

l = &i;

j = *k;

Ive also been told that this code crashes. The question is, explain the cause of the crash, and correct the program by rearranging the istructions without modifiying them.

Can someone help me to understand why it is crashing. Ive been told that line 4 is the problem, and that reversing line 2 and three fixes the problem.

Ive even been told it has something to do with dereferencing, but for the life of me I cant find any information or tutorials online that will help me understand what is going on.

Can anyone explain this to me?

Ive been given this code:

int i=0, j=0, *k=0, *l=0;

k = l;

l = &i;

j = *k;

Ive also been told that this code crashes. The question is, explain the cause of the crash, and correct the program by rearranging the istructions without modifiying them.

Can someone help me to understand why it is crashing. Ive been told that line 4 is the problem, and that reversing line 2 and three fixes the problem.

Ive even been told it has something to do with dereferencing, but for the life of me I cant find any information or tutorials online that will help me understand what is going on.

Can anyone explain this to me?