Home > Back-end >  K and I would like to ask about the return (int *) & (TMP); What's the meaning of, and any othe
K and I would like to ask about the return (int *) & (TMP); What's the meaning of, and any othe

Time:09-17

Void GameBox ()
{
Int I, j, k;
Color (14);
For (j=2; j<=22; J +=5)
{
Gotoxy (15, j);
For (k=1; K<42. K++)
{
Printf (" - ");//the lateral border of the printed board
}
printf("\n");
}
For (I=3; I<7. I++)
{
Gotoxy (15, I);
Printf (" | | | | | ");//print board vertical border
}
For (I=8; I<12. I++)
{
Gotoxy (15, I);
Printf (" | | | | | ");
}
For (I=13; I<17. I++)
{
Gotoxy (15, I);
Printf (" | | | | | ");
}
For (I=18; I<22. I++)
{
Gotoxy (15, I);
Printf (" | | | | | ");
}

Gotoxy (16, 1);
Color (11);
Printf (" game score: % ld ", score).
}

The ij here said ranks, k said what?




Int * add (int item [])
{
Int I=0, j=0;
Static int the teb [4]={0, 0, 0, 0}, TMP [4]={0, 0, 0, 0};
for(i=0; I & lt; 4. I + +)
{
If (item [I]!=0)//if the Numbers are there in this grid
{
The teb [j++]=item [I];
}
}

for(i=0; I<4. I++)
{
If (teb [I]==teb [I + 1))//if the same two Numbers, the merger
{
The teb [I] *=2;
The teb [I + 1)=0;
Score=score + teb [I];
}
}
J=0;
for(i=0; I & lt; 4. I + +)
{
If (teb [I]!=0)
{
TMP/j++=teb [I];
}
}
Return (int *) (& amp; TMP);
}

The return here (int *) (& amp; TMP); What's the meaning of, and any other written?

CodePudding user response:

Returns the address of the TMP, other way is to directly define a pointer, pointer to return

CodePudding user response:

TMP saw no definition

CodePudding user response:

 return TMP. 

Is this also can write,
Because the TMP is an array, array name is the first address of the array,

CodePudding user response:

& TMP is dross, TMP is generally regarded as the first address, more like a right value, can also take a address is beyond the wildest dreams,

But I tried the following is not an error,
& TMP is an int (*) [4], a pointer to the 4 times int array length, is my pointy-haired, this type in the past few insights,
Very interesting, however, has certain practical value,

So I have a views: & amp; TMP TMP is not here for the first address, and just as an array of reference
  • Related