Automatic and static variables

DEFINE _CRT_SECURE_NO_WARNINGS # // 
#include <stdio.h> 
#include <stdlib.h> 
/ * variable is automatically created when defining the system will automatically recover the space defined when their function returns the 
	local variable block statement, and formal parameters to functions are automatic variables 
	If you just let the program run up, auto can be omitted. auto allows more readable program 

* / 
void AutoRun () {   
	auto int X = 0; // automatic variables 
	// automatic variables, there is a function is called, the end of the call is released 
	// address has not changed, but the value was Per not the same call a 
	printf ( "% X \ n-", & X); 

} 

void staticRun () { 
	static int X = 0; // static variables 
	// static variables, each call, the address value did not change, and 
	printf ( "% X \ n-", & X); 
} 
void main () { 
	staticRun (); 

	the printf ( "\ n-"); 

	staticRun (); 

	System ( "PAUSE"); 
}

 

Guess you like

Origin www.cnblogs.com/luoxuw/p/11223044.html