Home > Back-end >  There was a little Pointers and arrays of problems
There was a little Pointers and arrays of problems

Time:10-01

A two-dimensional array [3] [3]
A pointer initialized to & amp; A [0] [0]
How can I make it point to a [2] [1]
Using pointer operations
#include
using namespace std;

Int main ()
{
Int x [3], [3]=,2,3,4,5,6,7,8,9 {1};
Int * p=& amp; X [0] [0];
Cout & lt; <* * ((int) (& amp; P + 2) + 1);

system("pause");
}

Error 1 error C4700: using an uninitialized local variable "p"

CodePudding user response:

#include
using namespace std;

Int main ()
{
Int x [3], [3]={1, 2, 3, 4, 5, 6, 7, 8, 9};
Int * p=(int *) (& amp; X [0] + 2) + 1;
Cout & lt; <* p;

system("pause");
}
Why did the can

CodePudding user response:

The problem is not you asked? Said no see rightly or wrongly, under xe7 can be compiled through,
#include
using namespace std;

Int main ()
{
Int x [3], [3]=,2,3,4,5,6,7,8,9 {1};
Int * p=& amp; X [0] [0];
Cout & lt; <* * ((int) (& amp; P + 2) + 1);

system("pause");
}

CodePudding user response:

The
reference 3 floor songhtao response:
the problem is not you asked? Said no see rightly or wrongly, under xe7 can be compiled through,
#include
using namespace std;

Int main ()
{
Int x [3], [3]=,2,3,4,5,6,7,8,9 {1};
Int * p=& amp; X [0] [0];
Cout & lt; <* * ((int) (& amp; P + 2) + 1);

system("pause");
}

Never asked ah,,, no see right and wrong, what meaning be

CodePudding user response:

reference 4 floor dx_cxgg123 response:
Quote: reference songhtao reply: 3/f

The problem is not you asked? Said no see rightly or wrongly, under xe7 can be compiled through,
#include
using namespace std;

Int main ()
{
Int x [3], [3]=,2,3,4,5,6,7,8,9 {1};
Int * p=& amp; X [0] [0];
Cout & lt; <* * ((int) (& amp; P + 2) + 1);

system("pause");
}

Not asked, and did not see, right and wrong, and what's the meaning of


Didn't read the operation result is correct

CodePudding user response:

P is the address, can't take the address
 # include & lt; iostream> 
using namespace std;

Int main ()
{
Int x [3], [3]=,2,3,4,5,6,7,8,9 {1};
Int * p=& amp; X [0] [0];
Cout & lt; <* * ((int) (p + 2) + 1);

system("pause");
}

  • Related