#include <stdio.h>
#include <stdlib.h>
int main()
{
int x, y ;
x =5;
y =10;
int z[ ] ={1,2,4,8,16};
printf(" The address of x is : %p\n\n " , &x);
printf(" The address of y is : %p\n\n " , &y);
printf(" The address of z[0] is : %p\n\n " , &z[0]);
int *testPtr = &x;
printf(" The value of x is : %i\n\n " , *testPtr);
*testPtr = *testPtr + 6; // wouldnt work otherwise
printf(" The address of x is : %i\n\n " , *testPtr);
if ( *testPtr > y)
{
printf(" x > y \n\n" );
}
else
{
printf(" x < y \n\n");
}
testPtr = &z[0];
[b] int count;
for ( count = 0 ; count < 4 ; count++)
{
printf( " The value of testPtr at %i \n\n", *testPtr +count);
}[/b]
return 0;
}
for ( count = 0 ; count < 5 ; count++)//use <5 or <=4 if you want all values in array
{
printf( " The value of testPtr at %i \n\n", *(testPtr +count));
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
int x, y ;
x =5;
y =10;
int z[ ] ={1,2,4,8,16};
printf(" The address of x is : %p\n\n " , &x);
printf(" The address of y is : %p\n\n " , &y);
printf(" The address of z[0] is : %p\n\n " , &z[0]);
int *testPtr = &x;
printf(" The value of x is : %i\n\n " , *testPtr);
printf(" The address of x is : %p\n\n " , testPtr);
if ( (*testPtr) > (y))
{
printf(" x > y \n\n" );
}
else
{
printf(" x < y \n\n");
}
testPtr = z;
int count;
for ( count = 0 ; count <= 4 ; count++)
{
printf( " The value of testPtr at %i \n\n", testPtr[count]);
// or printf( " The value of testPtr at %i \n\n", *(testPtr +count));
}
return 0;
}