自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(8)
  • 收藏
  • 关注

原创 strlen函数注意事项

例: #include<stdio.h> #include<string.h>//调用strlen函数要声明 int main() { char*p=“abcdr\0efghijk\0”;strlen函数扫描到\0后就会停止,只会记录abcde printf("%d\n",strlen§);//最后输出结果为5 return 0; }

2021-07-31 09:22:08 177

原创 Switch语句

switch( 变量i或者表达式) { case 常量表达式1 :…执行语句1 当变量i或者表达式与常量表达式1相等时,执行执行语句1 break; case 常量表达式2:…执行语句2 当变量i或者表达式与常量表达式2相等时,执行执行语句2 break; case 常量表达式3: case 常量表达式4:…执行语句3 当变量i或者表达式与常量表达式3或者4相等时

2021-07-20 20:18:31 94

原创 隐式类型转换

#include<stdio.h> void foo(void) { unsigned int a = 6; int b = -20; if((a+b)>6) // 6 + -20 == -14 -14 会变成14 printf(">6\n"); // a+b>6 else printf("<6\n"); printf("%u\n",(a+b)); //4294967282 } int main(int argc,char*argv[]) {

2021-07-17 16:59:27 95

原创 假设有一个int a,a有32位,位编号31~0,要求把a的第15位置1,但是其他位保持不变

#include<stdio.h> int main(int argc,char*argv[]) { int a; int b; printf(“请输入:\n”); scanf("%d",&a); b = 1; b = b <<15; \b左移15位 则第15位为1 ,其余为0 a = a|b; \ a 或b 因为第15位为1 ,则无论a的第15位为多少,最后运算结果a的第15位为1 printf(“a:%d\n”,a); return 0

2021-07-17 16:37:28 389

原创 假设有一个int a,a有32位,位编号31~0,要求把a的第20位清0,但是其他位保持不变

#include<stdio.h> int main(int argc,char*argv[]) { int a; int c; printf(“请输入:\n”); scanf("%d",&a); c = 1<<20; \1 的二进制左移20位 c = ~c; \取反 将第20位的1变成0 其他位全为1 a = a&c; \a与c 因为C的20位为0 所以无论a的20位为何数,结果a的第20位都会置0 pr

2021-07-17 16:32:21 437

原创 请算出一个字节中被置1的位的个数

#include<stdio.h> int main(int argc,char*argv[]) {     int a = 0;     char b = 0;     int i;     printf(“请输入:\n”);  &nbs

2021-07-17 16:25:14 227

原创 输入ASCII码值 程序输出相应的字符 编程

#include<stdio.h> #include<stdbool.h> intmain(intargc,char*argv[]) { printf("请输入ASCII码\n"); charvalue=0; scanf("%hhd",&value); printf("value:%c\n",value); return0; } #include<stdio.h> #include<stdboo...

2021-07-17 16:13:37 2286

原创 LINUX C语言学习(运算符)

关于逻辑运算符 真值表 逻辑 与 && 0 1 当只要双方有一方为1时 结果为1 0 0 0 1 0 1 逻辑 或 || ...

2021-07-17 16:09:53 62

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除