Níže jsou některá zajímavá fakta o programování v C:
1)
Popisky případu příkazu switch se mohou vyskytovat uvnitř příkazů 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: { } } }
výstup:
GeeksforGeeks2)
arr[index] je stejné jako index[arr] Důvodem, proč to funguje, je, že k prvkům pole se přistupuje pomocí aritmetiky ukazatele.
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; }
výstup:
13)
Můžeme použít '<: :>' místo '[]' a '<% %>' místo '{}'
C#include int main() <% int arr <:10:>; arr<:0:> = 1; printf('%d' arr<:0:>); return 0; %>
výstup:
14)
Použití #include na podivných místech. Nechť 'a.txt' obsahuje ('GeeksforGeeks');
CPP#include int main() { printf #include 'a.txt' ; }
výstup:
GeeksforGeeks5)
Vstup v scanf() můžeme ignorovat použitím '*' za '%' ve specifikátorech formátu
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; }