随笔分类 - C语言
摘要:c语言中baiu8,u16,u32和int区别为:du符号不同、数据范围不同、zhidao存占用空间不同。 一、符号数不同 1、u8:u8表示无符号char字符类型。 2、u16:u16表示无符号short短整数类型。 3、u32:u32表示无符号int基本整数类型。 4、int:int表示带符号i
阅读全文
摘要:1 #include<stdio.h> 2 //2020年11月23日20:58:58 3 int main(void) 4 { 5 double * p; 6 double x = 66.6; 7 8 p = &x;//x占8个字节,1个字节是8位,1个字节1个地址, 9 //p存放的是第一个字节
阅读全文
摘要:1 #include<stdio.h> 2 int main(void) 3 { 4 /* 5 int i; 6 int j; 7 printf("input number1:\n"); 8 scanf("%d",&i); 9 printf("input number2:\n"); 10 scanf
阅读全文
摘要:首先把方法放在前面: 再来看有趣的实验: 8位二进制所能表示的范围是多少呢? 让我们来看下(计算机中都是补码表示,所以下面的数字也都是补码) 从0000_0000到1111_1111, 其中0000_0000全零代表数字是零, 0000_0001到0111_1111因为首位是零,所以代表的是正整数,
阅读全文
摘要:什么是枚举? 把一个事物所有可能的取值一一列举出来。 枚举的优缺点? 代码更安全,但是书写麻烦 #include<stdio.h> enum WeekDay { MonDay,TuesDay,WednesDay,ThursDay,FriDay,SaturDay,SunDay }; void f(en
阅读全文
摘要:#include<stdio.h> #include<malloc.h> #include<string.h> //动态构造学生管理系统 struct Student { int age; float score; char name[100]; }; int main(void) { int le
阅读全文
摘要:#include<stdio.h> //冒泡排序 void sort(int * a,int len) { int i,j,t; for(i=0;i<len-1;i++) { for(j=0;j<len-1-i;j++) { if(a[j]>a[j+1])//>表示升序,<降序 { t=a[j];/
阅读全文
摘要:/* //2020年11月19日17:24:42 #include<stdio.h> #include<string.h> void InputStudent(struct Student); struct Student { int age; char sex; char name[100]; }
阅读全文
摘要:#include<stdio.h>//2020年11月19日16:46:44//修改结构体变量成员的值-两种方式struct Student{ int age; float score; char sex;};int main(void){ struct Student st = {11,23.3,
阅读全文
摘要:程序没有逻辑错误,因为子函数所占用的内存是动态分配的,存储在堆,而不是栈,静态内存之所以丢失是因为函数执行完毕要出栈,堆是手动分配的,函数执行完毕没有free就一直存在,所以p所指向空间不会丢失。 1 #include<stdio.h> 2 #include<malloc.h> 3 struct S
阅读全文
摘要:虽然程序没有报错,但有逻辑错误,因为f函数运行完毕,内存就会释放,此时*p所指向的地址存放的是一个垃圾值。
阅读全文
摘要:---------------------------------------------------------------------------------
阅读全文
摘要:1. malloch函数返回的是4个字节中的第一个字节的地址,那为什么要加强制类型转换呢,是因为根据第一个字节地址,可以把8个字节当一个变量也可以把4个字节当一个变量,所以malloc函数返回的是一个无意义的地址也就是干地址,所以需要告诉编译器我们返回的是哪种类型的地址,把第一个字节地址当成一个整形
阅读全文
摘要:#include<stdio.h> //2020年11月18日16:18:49 // int main(void) { char ch='a'; int i=99; double x=66.6; char * p=&ch; int * q=&i; double * r=&x; printf("%d,
阅读全文
摘要:#include<stdio.h> void f(int *pArr,int len) { int i; for(i=0;i<len;i++) { printf("%d\n",*(pArr+i)); printf("%#X\n",pArr+i); } } int main(void) { int a
阅读全文
摘要:#include<stdio.h> void huhuan_1(int,int); void huhuan_2(int *,int *); void huhuan_3(int *,int *); int main(void) { int a=3,b=5; //huhuan_1(a,b); //huh
阅读全文
摘要:转载https://blog.csdn.net/weixin_41126303/article/details/89843381?utm_medium=distribute.pc_relevant.none-task-blog-title-14&spm=1001.2101.3001.4242
阅读全文
摘要:#include <stdio.h> //2020年11月16日22:15:18 //本函数的功能是:判断m是否是素数,是返回true,不是返回false bool isprime(int m) { int i; for(i=2;i<m;i++) { if(m%i==0) break; } if(i
阅读全文

浙公网安备 33010602011771号