C 程式語言的侷限性


問題

與其他程式語言相比,C 程式語言有哪些侷限性?

解決方案

  • 與面向物件程式語言相比,C 語言沒有或者禁止了繼承、多型、封裝和資料抽象等概念。

  • C 程式語言不會檢測每一行程式碼的錯誤,它會在整個程式碼完成後檢查錯誤。

  • 它沒有名稱空間屬性。

  • C 程式設計的資料抽象能力不夠,即沒有很大的資料處理能力。

  • C 語言不允許使用者藉助異常處理功能檢測錯誤。

  • C 語言不支援建構函式和解構函式的概念。

  • 它不支援完全解決實際問題。

  • 與其他程式語言相比,它的安全性較低。

基本結構

\“C\”程式的一般結構如下 −

/* documentation section */
preprocessor directives
global declaration
main ( ){
   local declaration
   executable statements
}
return type function name (argument list){
   local declaration
   executable statements
}

示例

/* Author : Tutorialspoint
Aim : Program for finding circumference of circle*/
#include<stdio.h>
#include<conio.h>
#define PI 3.1415
main ( ){
   float c, r;
   clrscr ( );
   printf ("enter radius of circle");
   scanf ("%f", &r);
   c = 2 * PI * r;
   printf ("Circumference = %f", c);
   getch ( );
}

輸出

Enter radius of circle r=4
Circumference of circle c=25.132000

更新日期:2021-03-09

3 千次以上瀏覽

開啟您的 職業生涯

透過完成課程獲得認證

開始
廣告