Tuesday, July 11, 2006

static in C

The output is 1 2 3 4 5, ( 1 1 1 1 1 without static)
#include < >
using namespace std;

void static_function_example()
{
static int x = 0;
x++;
cout <<>
}

int _tmain(int argc, _TCHAR* argv[])
{
int array[3] = {2, 3, 4};
int length = 3;
for (int i = 0; i < 5; i++)
static_function_example();
return 0;
}

No comments:

Post a Comment