__DATE__和__TMIE__使用
#include<iostream>
using namespace std;
// 注意,是雙下劃線,而不是單下劃線 無需額外頭文件
// __FILE__ 包含當前程序文件名的字符串
// __LINE__ 表示當前行號的整數
// __DATE__ 包含當前日期的字符串
// __STDC__ 如果編譯器遵循ANSI C標準,它就是個非零值
// __TIME__ 包含當前時間的字符串
// __FUNCTION__執行函數
int main()
{
cout << __FILE__ << endl;
cout << __LINE__ << endl;
cout << __DATE__ << endl;
cout << __TIME__ << endl;
cout << __FUNCTION__ << endl;
}
結果:
va_list va_start va_arg va_end使用
#include <iostream>
#include <stdarg.h>
using namespace std;
int add(int totalnum...)// totalnum指定了參數的個數,...表示參數不定, 爲定義此類函數必需
{
va_list intlist;// 定義參數表 intlist
va_start(intlist, totalnum);// 指定開始參數爲totalnum
cout << totalnum << endl;
int totaladd = 0;
for (int i = 0; i < totalnum; i++)
{
totaladd += va_arg(intlist, int);// 取出參數類型爲int的參數 你說的fmt是參數的類型如float等
}
va_end(intlist);// 參數取完
return totaladd;
}
void main()
{
cout << add(5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) << endl;// 輸出 15
}
通用縮寫表
縮 寫 | 全 稱 |
---|---|
Addr | Address |
Adm | Administrator |
App | Application |
Arg | Argument |
Asm | assemble |
Asyn | asynchronization |
Avg | average |
DB | Database |
Bk | back |
bmp | Bitmap |
btn | Button |
buf | Buffer |
calc | Calculate |
char | Character |
chg | Change |
clk | Click |
clr | color |
cmd | Command |
cmp | Compare |
col | Column |
coord | coordinates |
cpy | copy |
ctl / ctrl | Control |
cur | Current |
cyl | Cylinder |
dbg | Debug |
dbl | Double |
dec | Decrease |
def | default |
del | Delete |
dest / dst | Destination |
dev | Device |
dict | dictionary |
diff | different |
dir | directory |
disp | Display |
div | Divide |
dlg | Dialog |
doc | Document |
drv | Driver |
dyna | Dynamic |
env | Environment |
err | error |
ex/ext | Extend |
exec | execute |
flg | flag |
frm | Frame |
func / fn | Function |
grp | group |
horz | Horizontal |
idx / ndx | Index |
img | Image |
impl | Implement |
inc | Increase |
info | Information |
init | Initial/Initialize/Initialization |
ins | Insert |
inst | Instance |
INT / intr | Interrupt |
len | Length |
lib | Library |
lnk | Link |
log | logical |
lst | List |
max | maximum |
mem | Memory |
mgr / man | Manage / Manager |
mid | middle |
min | minimum |
msg | Message |
mul | Multiply |
num | Number |
obj | Object |
ofs | Offset |
org | Origin / Original |
param | Parameter |
pic | picture |
pkg | package |
pnt / pt | Point |
pos | Position |
pre / prev | previous |
prg | program |
prn | |
proc | Process / Procedure |
prop | Properties |
psw | Password |
ptr | Pointer |
pub | Public |
rc | rect |
ref | Reference |
reg | Register |
req | request |
res | Resource |
ret | return |
rgn | region |
scr | screen |
sec | Second |
seg | Segment |
sel | Select |
src | Source |
std | Standard |
stg | Storage |
stm | Stream |
str | String |
sub | Subtract |
sum | summation |
svr | Server |
sync | Synchronization |
sys | System |
tbl | Table |
temp / tmp | Temporary |
tran / trans | translate/transation/transparent |
tst | Test |
txt | text |
unk | Unknown |
upd | Update |
upg | Upgrade |
util | Utility |
var | Variable |
ver | Version |
vert | Vertical |
vir | Virus |
Wnd | Window |