
在这里我们将看到一些有关 C 编程的有趣事实。如下所示。
#include <stdio.h>
main() {
int x = 2, y = 2;
switch(x) {
case 1:
;
if (y==5) {
case 2:
printf("Hello World");
}
else case 3: {
//case 3 block
}
}
}Hello World
数组[index]可以写成index[array]。原因是数组元素是使用指针算术访问的。 array[5] 的值为 *(array + 5)。如果像 5[array] 这样的顺序相反,那么也和 *(5 + array) 一样。
#include <stdio.h>
main() {
int array[10] = {11, 22, 33, 44, 55, 66, 77, 88, 99, 110};
printf("array[5]: %d</p><p>", array[5]);
printf("5[array]: %d</p><p>", 5[array]);
}array[5]: 66 5[array]: 66
#include <stdio.h>
main() <%
int array<:10:> = <%11, 22, 33, 44, 55, 66, 77, 88, 99, 110%>;
printf("array[5]: %d</p><p>", array<:5:>);
%>array[5]: 66
我们可以在一些奇怪的地方使用#include。这里让我们考虑文件 abc.txt 中包含“The Quick Brown Fox Jumps Over The Lazy Dog”这一行。如果我们在 printf 语句之后包含该文件,则可以打印该文件内容。
#include <stdio.h>
main() {
printf
#include "abc.txt" ;
}The Quick Brown Fox Jumps Over The Lazy Dog
#include <stdio.h>
main() {
int x;
printf("Enter two numbers: ");
scanf("%*d%d", &x);
printf("The first one is not taken, the x is: %d", x);
}Enter two numbers: 56 69 The first one is not taken, the x is: 69
以上就是有关C编程的有趣事实的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号