![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C语言
小优优爸爸
这个作者很懒,什么都没留下…
展开
-
C 宏和位操作
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。 #include "stdafx.h" #include "iostream" #include "stdio.h" int a = 1; //#define BIT3 (0x1 #define BIT(bit) (1 void set_bit(int* data, int bit原创 2016-04-11 15:22:22 · 874 阅读 · 0 评论 -
Sizeof与Strlen的区别与联系
Sizeof与Strlen的区别与联系 一、sizeof sizeof(...)是运算符,在头文件中typedef为unsigned int,其值在编译时即计算好了,参数可以是数组、指针、类型、对象、函数等。 它的功能是:获得保证能容纳实现所建立的最大对象的字节大小。 由于在编译时计算,因此sizeof不能用来返回动态分配的内存空间的大小。实际上,用sizeof转载 2017-08-06 16:52:51 · 301 阅读 · 0 评论 -
C sizeof 关键字
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。 //visual studio 2012 //sizeof 是一个关键字 而不是函数 sizeof在计算变量所占空间大小时括号可以省略 计算类型大小时不能省略 #include "stdafx.h" #include #include #include void fun(i原创 2016-04-24 21:50:38 · 239 阅读 · 0 评论 -
C 链表示例
// C链表的使用示范,存储学生的名字和编号 //测试环境 visual studio 2012 #include #include struct Student { char cName[20]; int iNumber; struct Student* pNext; }; int iCount = 0; struct Student* Create()原创 2016-04-16 19:00:31 · 277 阅读 · 0 评论 -
C 判断一个字节中置1的位个数
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。 // visual studio 2012 //移位判断是否为1 #include "stdafx.h" #include "iostream" #include "stdio.h" int count = 0; void Count_setbit(unsigned num) {原创 2016-04-22 14:52:45 · 2044 阅读 · 0 评论 -
C字符变量地址输出
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。 //字符变量取地址用C++流输出 需要强制转换void * #include "stdafx.h" #include #include #include char **p2; char *p1; char pp = 'A'; int **m2; int *m1; int原创 2016-04-17 07:55:57 · 611 阅读 · 0 评论 -
C 字符串指针与字符数组
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。 //visual studio 2012 系统分配时存储位置不一样 字符串指针在初始化时存储在静态区是常量,初始化后不能修改 //字符数组 是存放在栈中的,值是可以修改的 #include "stdafx.h" #include #include #include #include原创 2016-04-16 16:46:29 · 350 阅读 · 0 评论 -
C 关于变量a的那些乱七八糟的定义
// C链表的使用示范,存储学生的名字和编号 //测试环境 visual studio 2012 #include "stdafx.h" #include #include #include int a = 1; int *b = NULL; int **c = NULL; int d[10] = {1,1,1,1,1,1,1,1,1,1}; int *e[10原创 2016-04-27 17:21:05 · 519 阅读 · 0 评论 -
C 递归逆序输出字符串
//测试环境 visual studio 2012 // 递归时 将p+1 换成 p++ 将会一直递归到栈溢出出错 #include "stdafx.h" #include #include #include char str[] = "hello world"; void print_str(char *p) { if (*p != '\0') { pri原创 2016-04-27 11:00:17 · 881 阅读 · 0 评论 -
C 冒泡排序原理示范
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。 // visual studio 2012 // C 冒泡排序原理示范 #include "stdafx.h" #include "iostream" #include "stdio.h" //static int test_array[] = {1,2,3,4,5,6}; stati原创 2016-04-13 16:00:37 · 249 阅读 · 0 评论 -
C队列 数组实现
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。 // visual studio 2012 // 一个长度为10的队列的数组实现操作 // 对应C++中的操作函数 入队push(),出队pop(), 读取队首元素front(),读取队尾元素back() // 判断队是否有元素empty(),求队列元素个数size() #includ原创 2016-04-12 17:39:01 · 841 阅读 · 0 评论