c語言庫函數測試
阿新 • • 發佈:2017-05-29
print 異常終止 不存在 eache 函數名 mode .com src 參數
1.函數名: abort
功 能: 異常終止一個進程
用 法: void abort(void);
程序例:
1 #include <stdio.h> 2 #include <stdlib.h> 3 int main(void) 4 { 5 printf("Calling abort()\n"); 6 abort(); 7 printf("hello\n"); /* This is never reached */ 8 }
結果:abort後面的代碼不會執行,程序會從abort處終止,報異常
2.函數名: abs
功 能: 求整數的絕對值
用 法: int abs(int i);
程序例:
1 int main(void) 2 { 3 int number = -1234; 4 char a = -12; 5 printf("number: %d absolute value: %d\n", number, abs(number)); 6 printf("number: %d absolute value: %d\n", a, abs(a)); 7 getchar(); 8 }
結果:返回一個整數絕對值,參數必須為整數,否則會出錯
3.函數名: access
功 能: 確定文件的訪問權限
用 法: int access(const char *filename, int amode);
1 #include <stdio.h> 2 #include <io.h> 3 4 int main(void) 5 { 6 printf("Does NOTEXIST.FIL exist: %s\n"); 7 int exist = _access("E:\\MM.txt", 0); 8 printf("文件存在否:%s", exist == 0 ? "存在" : "不存在"); 9 system("pause"); 10 }
c語言庫函數測試