用法:
printf("%d\n",sizeof(int));
//計算int型別所佔的位元組數,結果爲:4
int num[] = {1,2,3};
printf("%d\n",sizeof(num));
//計算num陣列所佔的位元組數,結果爲:4*3 = 12
用法:
printf("%d\n",__LINE__);
//列印當前行數
用法:
printf("%s\n",__func__);
//列印當前所在函數
原名:Buffer size
This macro constant expands to an integral expression with the size of the
buffer used by the setbuf function.
用法:
printf("%d\n",BUFSIZ);
// 64位元系統下結果爲:8192
原名:end of file
It is a macro definition of type int that expands into a negative integral constant expression (generally, -1).
It is used as the value returned by several functions in header <cstdio> to indicate that the End-of-File has been reached or to signal some other failure conditions.
It is also used as the value to represent an invalid character.
用法:
int num;
while(scanf("%d",&num)!=EOF);
//代表只要沒有按下CTRL+c就一直回圈
原名:Potential limit of simultaneous open streams
This macro constant expands to an integral expression that represents the maximum number of files that can be opened simultaneously.
Particular library implementations may count files opened by tmpfile towards this limit. Implementations may also allow more files to be opened beyond this limit.
FOPEN_MAX shall be greater than 7 on all systems.
用法:
printf("%d\n",FOPEN_MAX);
// 64位元系統下結果爲:16
原名:Minimum length for temporary file name
This macro constant expands to an integral expression corresponding to
the size needed for an array of char elements to hold the longest file name
string possibly generated by tmpnam.
用法:
printf("%d\n",L_tmpnam);
// 64位元系統下結果爲:20
原名:Number of temporary files
This macro expands to the minimum number of unique temporary file
names that are guaranteed to be possible to generate using tmpnam.
This value cannot be lower than 25.
Particular library implementations may count file names used by files created with tmpfile towards this limit.
用法:
printf("%d\n",TMP_MAX);
// 64位元系統下結果爲:238328
原名:Null pointer
This macro expands to a null pointer constant.
CC++98C++11:
A null-pointer constant is an integral constant expression that evaluates to
zero (like 0 or 0L), or the cast of such value to type void* (like (void*)0).
A null pointer constant can be converted to any pointer type (or pointer-to-
member type), which acquires a null pointer value. This is a special value
that indicates that the pointer is not pointing to any object.
用法:
int *p = NULL;
//把p指針初始化爲空指針
原名:Maximum length of file names
This macro constant expands to an integral expression corresponding to the size needed for an array of char elements
to hold the longest file name string allowed by the library. Or, if the library imposes no such restriction,
it is set to the recommended size for character arrays intended to hold a file name.
用法:
printf("%d\n",FILENAME_MAX);
// 64位元系統下結果爲:4096