Static
I. backgroundCause: when the program executes the variable defined in the function to its definition, the compiler allocates space for it on the stack, the space allocated by the function on the stack is released at the end of the function execution. This creates a problem: If you want to save the value of this variable in the function to the next call, how to implement it?The easiest way to think of is to define a global variable, but defining
I. Usage of typedef:
①Define a type of Alias, not just a simple macro replacement. It can be used to declare multiple objects of the pointer type at the same time. Trap: typedef char * tchar;
Tchar Pa, PB; // Pa and Pb are pointer types. # Define cannot achieve this effect.
Trap: typedef char * pstr;
Int mystrcmp (const pstr, const pstr); const pstr is equivalent to char? No, it is actually equivalent to ch
In PHP constant and define are constants then I would like to introduce a method to achieve dynamic use of constant and define value method, I hope you have some help.
How do you use PHP to show or use dynamic Constant/define values? Ex: The following example is a dynamic variable, but how is dynamic Constant used?
The code is as follows
Copy Code
PHP defines several constants in advance and provides a mechanism to define them at run time. Constants and variables are basically the same, and the difference is that constants must be defined with the Define function, which, once defined, cannot be redefined.
Pre-defined constants in PHP:
__file__
The file name of the script currently being processed. If used in a contained file, then its value is the co
A static
1) Background
Cause: when the program executes the variable defined in the function to its definition, the compiler allocates space for it on the stack, the space allocated by the function on the stack is released at the end of the function execution. This creates a problem: If you want to save the value of this variable in the function to the next call, how to implement it?
The easiest way to think of is to define a global variable, but defi
First, #define1. Just as an identifier:#define作为标识符时是没有参数的2, as a macro:the difference between #define as a macro and it as an identifier is that the macro has parameters and the identifier does notFor example: #define MAX (x, y) > (Y)? ( X):(Y))The difference between a macro and a function1, macro in use (compile phase) will be directly replaced (that is, simple
PHP uses array_fill to define multi-dimensional arrays. PHP uses array_fill to define multi-dimensional arrays. This article mainly introduces how PHP uses array_fill to define multi-dimensional arrays. The example shows how to use the array_fill function in php, has a PHP method to define multi-dimensional arrays usin
1. define the constant define (quot; constantquot;, quot; helloworld. quot;); constants can only contain scalar data (boolean, integer, floa... 1. define the constant define ("constant", "hello world. ");
Constants can only contain scalar data (boolean, integer, float, and string ).
When calling a constant, you only n
How do I define it without defining it?
Is it similar to the if define in C language??
If you can find it in the PHP manual, please.
Like what:
defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/');
Reply content:
How do I define it without defining it?Is it similar to the if
In Java EE applications, the data source object DataSource objects is a way to access relational databases through the jdbc api. Each DataSource object has a series of attributes used to describe the data source in the real world. These attributes can be used to describe the address, database name, network protocol, and other information of the database server. In addition, the data source object can be used with JNDI. If you bind a data source to a registered JNDI service, you can access the jn
Define section:Macros can be used instead of constant values, and can be used instead of expressions, even code snippets. (Macros are powerful, but error-prone, so their pros and cons are quite controversial.) )The syntax for a macro is:Macro value #define Macro nameAs a recommendation and a common practice for a broad range of programmers, macro names often use all uppercase letters.
Advantages of usi
# Ifndef/# define/# endif usage in c/c ++ header files,
Presumably many people have read "# ifndef/# define/# endif used in the header file to prevent this header file from being repeatedly referenced ". But can you understand the meaning of "being repeatedly referenced? What will happen if the header file is repeatedly referenced? Is it necessary to add # ifndef/# defi
Copy Code code as follows:
#include /*typedef char * string;
int main (void){String a[] = {"I", "like", "to", "Fight,"},B[] = {"Pinch,", "and", "Bight."};printf (%s%s%s%s%s\n ", A[0], a[1], a[2], a[3], b[0], b[1], b[2]);return 0;}
Replace the row of the TypeDef with #define, and the #define example that has been given cannot pass, but a single character can be added to the program.
====
The Magic usage of C + + macro commands.
First look at the following three statements:
#define CONN (x,y) x# #y
#define TOCHAR (x) #@x
#define TOSTRING (x) #x
1. # # Connection operator
# #表示连接 (token pasting, or token concatenation,merge two tokens into one while expanding macros). x# #y表示什么. Represents x connection Y, for example:
int n = Conn (123,456);
1) #define是preprocessing Directives, which is performed when the preprocessing is compiledsimple substitution, no correctness check, whether the meaning is correct or not, only when compiling the source program has been expanded to find possible errors and error.
For example: #define PI 3.1415926 Program: Area=pi*r*r will be replaced with 3.1415926*r*r if you write the number 9 in the #
Macro definition in C # define usage,
# Define is a macro definition Command provided in C language. Its main purpose is to provide programmers with some convenience in programming and improve the program running efficiency to a certain extent, however, when learning this command, students often cannot understand the essence of the command, and there is always some confusion here. The command is misused dur
# Define is a macro definition Command provided in C language. Its main purpose is to provide programmers with some convenience in programming and improve the program running efficiency to a certain extent, however, when learning this command, students often cannot understand the essence of the command, and there is always some confusion here. The command is misused during programming, so that the program runs differently from the expected purpose, or
Value of Do{}while (0) When macro definition (#define) in C languageRecently found in the code of the new company everywhere used do{...} while (0), Google a bit, found that stack overflow early on a lot of discussion, summed up the discussion, coupled with their own understanding, do{...} while (0) the value is mainly reflected in:1. Increase the adaptability of the CodeThe following macro definition does not use do{...} while (0)#
In applications, define is often used to define common parameter information to increase program readability and reliability.
In PHP, the constant name is a simple identifier, which cannot be changed during the execution period and is case sensitive by default. Constants are always capitalized.
Note: The third parameter in define can be used to set whether the co
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.