下面是一些关于C编程的有趣事实:
null
1) switch语句的大小写标签可以出现在if-else语句中。
#include <stdio.h> 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 program to demonstrate that arr[0] and // 0[arr] #include<stdio.h> int main() { int arr[10]; arr[0] = 1; printf ( "%d" , 0[arr] ); return 0; } |
输出:
1
3) 我们可以用“”代替“[,]”,用“”代替“{,}”
#include<stdio.h> int main() <% int arr <:10:>; arr<:0:> = 1; printf ( "%d" , arr<:0:>); return 0; %> |
输出:
1
4) 在陌生的地方使用#include。 让“a.txt”包含(“Geeksforgeks”);
#include<stdio.h> int main() { printf #include "a.txt" ; } |
输出:
GeeksforGeeks
5) 我们可以通过在格式说明符中的“%”后面使用“*”来忽略scanf()中的输入
#include<stdio.h> 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; } |
本文由 严酷的阿加瓦尔 .如果你喜欢GeekSforgek,并想贡献自己的力量,你也可以使用 贡献极客。组织 或者把你的文章寄到contribute@geeksforgeeks.org.看到你的文章出现在Geeksforgeks主页上,并帮助其他极客。
如果您发现任何不正确的地方,或者您想分享有关上述主题的更多信息,请写下评论。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END