How do you track the value that a function returns?

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
4TN
Posts: 5
Joined: April 12th, 2012, 8:54 pm
Location: Alton, IL USA

How do you track the value that a function returns?

Post by 4TN » October 26th, 2012, 11:07 pm

I am working with an example program on recursive functions and I followed the variables in the debugger. When the program was done it output a value that doesn't show in the autos window and there is basically one variable.

Code: Select all

// recursive-factorial.cpp by Bill Weinman <http://bw.org/>
#include <iostream>
using namespace std;

unsigned long int factorial( unsigned long int n ) {
	if( n < 2 ) return 1;
	return factorial( n - 1 ) * n;
}

int main( int argc, char ** argv ) {
	unsigned long int n = 10;
	cout << "factorial of " << n << " is " << factorial(n) << endl;
	return 0;
}
So where does the number come from and how do I track the value that a function returns?
"Programming is awesome, it's like the ultimate Legos" - Chili

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: How do you track the value that a function returns?

Post by chili » October 27th, 2012, 1:36 am

It should appear in the autos tab if you step into the function you're interested in and then step out of it.
Chili

4TN
Posts: 5
Joined: April 12th, 2012, 8:54 pm
Location: Alton, IL USA

Re: How do you track the value that a function returns?

Post by 4TN » October 27th, 2012, 3:48 am

I got it. Thanks Chilli.
"Programming is awesome, it's like the ultimate Legos" - Chili

Post Reply