Random commentary about Machine Learning, BigData, Spark, Deep Learning, C++, STL, Boost, Perl, Python, Algorithms, Problem Solving and Web Search
Wednesday, May 5, 2010
What direction is the stack growing?
You are working on a machine / compiler and you want to determine if the stack is growing towards increasing or decreasing addresses. What strategy would you use?
void func ( const int arg1, const int arg2 )
ReplyDelete{
if ( &arg1 > &arg2 ) // args pushed right to left in c
{
cout << "Stack grows up" << endl;
}
else
{
cout << "Stack grows down" << endl;
}
}