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]는 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  ;      }   
퀴즈 만들기