עובדות מעניינות בתכנות C

להלן כמה עובדות מעניינות על תכנות C:

1)

תוויות האותיות של משפט switch יכולות להופיע בתוך הצהרות if-else.

C
   #include         int     main  ()   {      int     a     =     2       b     =     2  ;      switch  (  a  )      {      case     1  :      ;      if     (  b  ==  5  )      {      case     2  :      printf  (  'GeeksforGeeks'  );      }      else     case     3  :      {      }      }   }   

פלט:

 GeeksforGeeks  

2)

arr[index] זהה לאינדקס[arr] הסיבה לכך היא שהגישה לרכיבי מערך היא באמצעות אריתמטיקה מצביע.

C
   // C program to demonstrate that arr[0] and   // 0[arr]   #include      int     main  ()      {      int     arr  [  10  ];      arr  [  0  ]     =     1  ;      printf  (  '%d'       0  [  arr  ]     );          return     0  ;      }   

פלט:

 1  

3)

אנחנו יכולים להשתמש ב' <: :>' במקום '[]' ו-' <% %>' במקום '{}'

C
   #include      int     main  ()    <%      int     arr      <:  10  :>  ;      arr   <:  0  :>     =     1  ;      printf  (  '%d'       arr   <:  0  :>  );      return     0  ;   %>   

פלט:

 1  

4)

שימוש ב-#include במקומות מוזרים. תן 'a.txt' להכיל ('GeeksforGeeks');

CPP
   #include      int     main  ()   {      printf      #include     'a.txt'      ;   }   

פלט:

 GeeksforGeeks  

5)

אנו יכולים להתעלם מקלט ב-scanf() באמצעות '*' אחרי '%' במפרטי הפורמט

C
   #include      int     main  ()   {      int     a  ;      // Let we input 10 20 we get output as 20      // (First input is ignored)      // If we remove * from below line we get 10.      scanf  (  '%*d%d'       &  a  );      printf  (     '%d '       a  );         return     0  ;      }   
צור חידון