[Dev-C++] =?utf-8?q?Pointer_location?=
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <ba...@o2...> - 2007-08-24 11:05:37
|
Hi.
Could=20you=20tell=20me,=20why=20pointer=20'pa'=20shows=206=20element=20o=
f=20the=20table=20(x[6]).=20Why=20it=20does=20not=20show=20second=20eleme=
nt?=20Here=20is=20the=20code:
#include=20<cstdlib>
#include=20<iostream>
#include=20<stdio.h>
#include=20<conio.h>
using=20namespace=20std;
struct=20bartek=20{
=20=20=20=20=20=20=20=20=20int=20a;
=20=20=20=20=20=20=20=20=20char=20c[4];
=20=20=20=20=20=20=20=20=20int=20b;
}=20*wsk1=5Fbartek;
int=20x[1000];
int=20main(int=20argc,=20char=20*argv[])
{
=20=20=20=20system("PAUSE");
=20=20
=20=20=20=20bartek=20*pa;
=20=20=20=20
=20=20=20=20pa=20=3D=20(bartek*)=20x;
=20=20=20=20
=20=20=20=20for(int=20i=20=3D=200=20;=20i=20<=20100;=20++i)=20=20=20{
=20=20=20=20=20=20=20=20=20=20=20=20x[i]=20=3D=20i;
=20=20=20=20}
=20=20=20=20
cout=20<<"=20After=20shift=20+2:=20"=20<<=20(pa+2)->a=20<<=20endl;
=20=20=20=20
cout=20<<"=20Global=20object=20read=20on=206=20position=20x[6]:=20"=20<<=20=
x[6]
<<=20endl;
=20
=20=20=20=20system("PAUSE");
=20=20=20=20return=20EXIT=5FSUCCESS;
}
...and=20here=20is=20the=20output:
Press=20any=20key=20to=20continue...
After=20shift=20+2:=206
Global=20object=20on=206=20position=20x[6]:=206
Press=20any=20key=20to=20continue...
|