获得栈的位置
下面的这个foo可以获得栈地址,最后显示1.4:
#include <cstdlib>
#include <iostream>
using namespace std;
void* pbase;
void foo (int a)
{
pbase = (void*)&a;
}
void push (double a)
{
cout << *(double*)pbase;
}
int main(int argc, char *argv[])
{
foo (4);
push (1.4);
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
using namespace std;
void* pbase;
void foo (int a)
{
pbase = (void*)&a;
}
void push (double a)
{
cout << *(double*)pbase;
}
int main(int argc, char *argv[])
{
foo (4);
push (1.4);
system("PAUSE");
return EXIT_SUCCESS;
}