C++ Function Definition automatic local variables created each time a function is called

Description

C++ Function Definition automatic local variables created each time a function is called

#include <iostream>
using namespace std;
void testauto();    // function prototype
int main()//from  ww  w .  jav  a  2 s.com
{
   int count;        // count is a local auto variable
   for (count = 1; count <= 3; count++)
      testauto();
   return 0;
}
void testauto()
{
   int num = 0;      // num is a local auto variable
   // initialized to 0
   cout << "The value of the automatic variable num is " << num << endl;
   num++;
   return;
}



PreviousNext

Related