// Pointers and static variables:
// Functions can have local static variables.
// Local static variable is initialized only once.

// Casual use of static variables can be dangerous
// in multithreaded programs. In turn, adding safety
// features could lead to platform-specific, non-portable
// code. Unless you absolutely must, stay away from global
// and static variables in your programs.

// Seeing static variables in someone else's code may indicate
// a design flaw, so be alert.

// However! Constant static or global data is very safe and
// desirable.

#include <iostream>
using namespace std;

int* print_message( char* msg )
{
	static int result = 0;
	cout << msg;
	result = 1;
	return &result;
}

int main()
{
	"HELLO"; // text, char array, "string literal" H E L L O \0
	//                                             `-> ptr to 'H'
	char* ptr_greeting = "HELLO";
	print_message( ptr_greeting );
	int* ptr_result = print_message( "BYE" );
	*ptr_result = 1000;
	return 0;
}