C語言 常用函式(一)

2021-07-31 07:06:17 字數 499 閱讀 2487

參考部落格:

atof() 將字串轉換為雙精度浮點型值

atoi() 將字串轉換為整型值

atol() 將字串轉換為長整型值

strtod() 將字串轉換為雙精度浮點型值,並報告不能被轉換的所有剩餘數字

strtol() 將字串轉換為長整值,並報告不能被轉換的所有剩餘數字

strtoul() 將字串轉換為無符號長整型值,並報告不能被轉換的所有剩餘數字

整型轉字串函式

char * int2str(int num)

; int i = 0;

int len = 0;

while(num != 0)

result[i] = '\0';

len = strlen(result);

for(i = 0; i < len / 2; i++) //前後換順序

return result;

}

C語言筆記 常用函式(一)

1.strcpy 函式用於對字串進行複製 拷貝 標頭檔案 string.h 原型 char strcpy char strdestination,const char strsource 引數說明 strdestination 目的字串 strsource 源字串 strcpy 函式會把 源字串複製...

C語言常用函式

字串操作函式 記憶體操作函式 file fopen char filename,char type int fclose file stream 返回非0值關閉成功 開啟方式 說明 r 以 唯讀 方式開啟檔案。只允許讀取,不允許寫入。檔案必須存在,否則開啟失敗。w 以 寫入 方式開啟檔案。如果檔案不...

C語言常用函式

1.atoi函式,將命令列輸入的字串常數轉為整型。在 include中。2.strtok函式,將一串字串分隔。include中 注意上面str為null時是從上一次停止位置的後面開始的。例如 include include intmain void printf after split,the st...