Įdomūs C programavimo faktai

Žemiau yra keletas įdomių faktų apie C programavimą:

1)

Switch sakinio didžiųjų ir mažųjų raidžių etiketės gali būti if-else teiginiuose.

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

Išvestis:

 GeeksforGeeks  

2)

arr[index] yra toks pat kaip index[arr] Priežastis, kodėl tai veikia, yra ta, kad masyvo elementai pasiekiami naudojant rodyklės aritmetiką.

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  ;      }   

Išvestis:

 1  

3)

Mes galime naudoti <: :>" vietoje "[]" ir " <% %>' vietoje '{}'

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

Išvestis:

 1  

4)

#include naudojimas keistose vietose. Tegul „a.txt“ yra („GeeksforGeeks“);

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

Išvestis:

 GeeksforGeeks  

5)

Galime nekreipti dėmesio į įvestį scanf() formato specifikacijose naudodami „*“ po „%“

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  ;      }   
Sukurti viktoriną