C++ Pointers

#include <iostream>
#include <windows.h>
using namespace std;

int main()
{
    int *tal1[10],tal[10],e=78;
    tal1[0] = &e;
    tal[0] = *tal1[0];
    *tal1[0] = 10;
    cout << e << endl << tal[0] << endl;
    cin.get();
    return 0;
}


I wanna know how I shall be able to point at the variable e without actually point at the variable t.ex
tal1[0] = &78; and it points at e's adress cuz it got it is 78

Last edited on
&78 will attempt to get the address of the literal. It will never give you the address of the variable e
so there are no real way to get e's adress with the fact that u know e is 78?
Last edited on
closed account (S6k9GNh0)
To get the address of e, use &e. 78 is nothing. It doesn't hold memory (well it does but not really) so point to the address of 78 is very invalid. 78 does NOT point to e, just because e = 78. As far as I know, 78 isn't a valid variable name either, I'm not sure where your confusion began.

There is also no point in this line: #include <windows.h>
Last edited on
ah that Im testing out the pointer function and sometime I need the sleep function in include file windows.h so short I was to lazy to take it out

anyway isnt there anyway to search throught and find all adress with the worth 78 somehow?
and then somehow find a way to determine which adress is for variable e?
Last edited on
Don't do that. Some other byte may have 78.

Plus, you don't always know what your valid addresses are. Typically, the first page (512 addresses) are not valid addresses for error detection reasons.
Topic archived. No new replies allowed.