从新认识了不少的标识符,其实以前大多的代码里都有所体现,有少数没有用过的,我着重的进行了记忆,而且实现了一些例题;ide
#include <stdio.h> int main() { int num = 0; //找出num中的二进制位中的1的个数 scanf("%d", &num); int i = 0; int count = 0; for (i = 0; i < 32; i++) { if (1 == ((num >> i) & 1)) count++; } printf("%d", count); return 0; }
以上表现了右移标识符的一种用法,右移标识符只是将数字对应的二进制位进行右移,左移标识符择优算数左移和逻辑左移,编译器中的是算术左移,会保留符号位,数据存储的时候都是存为补码的形式,正数原码等于补码,负数的补码等于原码按位取反再加一。指针
struct Stu { char name[20]; int age; char id[20]; }; #include <stdio.h> int main() { struct Stu s1 = { "张三",20,"2020012111" }; printf("%s\n", s1.name); printf("%d\n", s1.age); printf("%s\n", s1.id); struct Stu* ps = &s1; printf("%s\n", (*ps).name); printf("%s\n", ps->name); //-> 结构体指针指向操做符 return 0; }
其中的指向地址的操做符明显比直接用名称打印方便多了。code
#include <stdio.h> int main() { char a = 127; char b = 3; char c = a + b; printf("%d\n", c); int x = 1; printf("%d\n", x + --x);//无心义的算式 return 0; }
在不一样的编译器中会有不一样的结果编译器
#include <stdio.h> int main() { int i = 1; int a = (++i) + (++i) + (++i); printf("%d %d\n", a, i); return 0; }
要经过操做符肯定惟一的计算路径,那么这个表达式才是正确的。因此上面的代码时错误的,在 Linux系统中的执行结果为10it