Storage for automatic local variables is created automatically each time a function is called. - C++ Function

C++ examples for Function:Function Creation

Description

Storage for automatic local variables is created automatically each time a function is called.

Demo Code

#include <iostream>
using namespace std;
void testauto();    // function prototype
int main()//from   w w w.  java 2s . c o  m
{
   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;
}

Result


Related Tutorials