c語言庫函數測試

來源:互聯網
上載者:User

標籤:blog   val   div   idt   執行   技術   const   lin   getc   

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語言庫函數測試

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.