// sizeof
int main()
{
//short s= 0;
//int a = 10;
//
//printf("%d\n", sizeof(s = a + 5));//2
//printf("%d\n", s);//0这个是值 s=0
/*int a = 0;
char b = 'w';
int arr[10] = { 0 };
printf("%d\n", sizeof(a));
printf("%d\n", sizeof(int));
printf("%d\n", sizeof(b));
printf("%d\n", sizeof(char));
printf("%d\n", sizeof(arr));
printf("%d\n", sizeof(int [10]));*/
return 0;
}
//~--按位(二进制位)取反
int main()
{
int a = 11;
a = a | (1 << 2);
printf("%d\n", a);//15
a = a & (~(1 << 2));
printf("%d\n", a);//11
//0000000000000000000000001011
//0000000000000000000000000100
//1<<2
//0000000000000000000000000000
// ///1111111111111111111111111111-补码
// ///1111111111111111111111111110-反码
// ///1000000000000000000000000001-原码
// -1
int a = 0;
printf("%d\n", ~a);
return 0;
}
//++
int main()
{
int a = 10;
//printf("%d\n", ++a);//前置++,先++,后使用
printf("%d\n", a++);//后置++,先使用,再++
return 0;
}
//强制类型转换
int main()
{
int a = (int)3.14;
return 0;
}
//逻辑操作符
int main()
{
int i = 0, a = 0, b = 2, c = 3, d = 4;//a=1时答案是 2 3 3 5 i=1(为真)
i = a++ && ++b && d++;
printf("a=%d\n b=%d\n c=%d\n d=%d\n",a,b,c,d);
return 0;
}
//函数调用操作符
int get_max(int x, int y)
{
return x > y ? x : y;
}
int main()
{
int a = 10;
int b = 20;
int max=get_max(a, b);
printf("%d\n", max);
return 0;
}
//学生
//int float
//创建了一个结构体类型-struct stu
struct stu
{
char name[20];
int age;
char id[20];
};
int main()
{
int a = 10;
使用struct stu这个类型创建了一个学生对象s1,并初始化
struct stu s1 = { "张三",20,"2023410105" };
struct stu* ps = &s1;
printf("%s\n", ps->name);
printf("%d\n", ps->age);
/*printf("%s\n", (*ps).name);
printf("%d\n", (*ps).age);*/
printf("%s\n", s1.name);
printf("%d\n", s1.age);
printf("%s\n", s1.id);
//结构体变量.成员名
return 0;
}