Hi, i'm working with pointers and references and wanted to try out a simple program with an array. One variable will store the adresse of the first element in the array, than - the array will be increamented to the next element, and thus will reassign the new adress to a variable. I thought this would be simple but, well its not =/.
Code:
#include <iostream.h>
#include <stdlib.h>
int main() {
double a[100];
double *pVar; //create pointer to variable
pVar = &a[000]; //store adresse in pVar
do { //reiterate through untill done
if (&a[001] < &a[099], ++&a[000]) { //check if adresse of a[001] is less than next in array...
pVar = &++a[001]; //assign new adresse to pVar
cout << "adresse of a[???] = " << pVar; } //print new adress
else { //when done...
cout << "done";
system("PAUSE"); }
while(1); //loop while
return(0); //return 0 to exit
}
}
It is supposed to print the adresses of 99 array elements consecutavily. I'm not profficient in memory adresses so, please excuse me if this is a silly error...