Zanimljive činjenice o C programiranju

Ispod su neke zanimljive činjenice o C programiranju:

1)

Oznake velikih i malih slova naredbe switch mogu se pojaviti unutar naredbi 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  :      {      }      }   }   

Izlaz:

 GeeksforGeeks  

2)

arr[index] je isti kao index[arr] Razlog zašto ovo radi je što se elementima niza pristupa pomoću aritmetike pokazivača.

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

Izlaz:

 1  

3)

možemo koristiti ' <: :>' umjesto '[]' i ' <% %>' umjesto '{}'

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

Izlaz:

 1  

4)

Korištenje #include na čudnim mjestima. Neka 'a.txt' sadrži ('GeeksforGeeks');

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

Izlaz:

 GeeksforGeeks  

5)

Možemo ignorirati unos u scanf() upotrebom '*' nakon '%' u specifikacijama formata

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