- 博客(34)
- 收藏
- 关注
转载 友元
#define _CRT_SECURE_NO_WARNINGS #include <iostream>#include <string>using namespace std;class Building{ //让全局的好基友函数变为好朋友 friend void goodGay(Building * building);public:...
2018-12-27 10:48:45
194
原创 构造函数与析构函数
Test t3 //调用类的无参数构造函数//显示提供一个有参的构造方法,默认的构造函数不复存在Test(int x, int y){ m_x = x; m_y = y}
2018-12-05 11:49:32
172
原创 类的基本使用方法
#define _CRT_SECURE_NO_WARNINGS #include <iostream>using namespace std;struct Hero{ char name[64]; int sex;};void printHero(struct Hero &h){ cout << "name=" <&l...
2018-12-02 14:01:43
1192
翻译 const
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct MyStruct{ int a; int b;}MyStruct;void fun(MyStruct *p){ //...
2018-11-16 17:39:52
166
转载 字符作业
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>/*4. 键值对(“key = value”)字符串,在开发中经常使用要求1:请自己定义一个接口,实现根据key获取.要求2:编写测试用例。要求3:键值对中间可能有n多空格...
2018-11-15 17:23:15
151
原创 字符串常识
一、指针强化1、指针也是一种数据类型,指针变量也是一种变量,和int a本质是一样的 1)指针变量也是一种变量,也有空间,32位程序大小为4个字节 int *p = 0x1122; 2)*操作符,*相当于钥匙,通过*可以找到指针所指向的内存区域 int a = 10; int *p = NULL; p = &a; //指针指向谁,...
2018-11-15 15:34:25
296
原创 栈区返回变量的值和变量的地址区别
int fun() { int a = 10; return a; } int *fun2() { int a = 10; return &a; } int *fun3() { static int a = 10; r...
2018-11-15 14:57:58
878
1
原创 两头堵模型
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>int main(void){ char *p = " abcdefg "; int begi...
2018-11-15 12:30:21
213
原创 strstr
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int main(void){ char *p = "abcedabc"; int n = 0; do{ p = strstr(p, "ab...
2018-11-14 14:28:52
296
原创 字符串的初始化
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>/*c语言没有字符串类型,通过字符数据模拟 C语言字符串,以字符‘\0’, 数字0*/int main01(void){ //不指定长度, 没有0结束符,有多少个...
2018-11-13 13:46:02
16226
原创 值传递与地址传递
void fun2(int *p){ p = 0xaabb; printf("fun2:p = %p\n", p);}void fun3(int **p){ *p = 0xeeff;}int main(void){ int *p = 0x1122; printf("p1 = %p\n", p); fun2(p); //值传递 ...
2018-11-09 09:05:44
158
原创 形参与实参
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int get_a() { int a = 10; //栈区 return a;}void get_a2(int b){ b = 22;...
2018-11-01 17:32:17
144
原创 数组拷贝与堆栈拷贝区别
· char buf[] = "abc"; //buf指向常量区“abc”,拷贝到栈区buf,编译器检测到是数组,地址0x11,//注意这里没有指向关系 char *p = NULL; char *q = NULL; int i = 0; q = (char *)malloc(100); //q分配100个字节在堆里,q指向0x11这片空间 i...
2018-11-01 16:56:17
294
转载 堆区分配内存
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int main(void){ char *p = NULL; char *q = NULL; int i = 0; q = (char *)m...
2018-11-01 16:48:42
209
原创 c语言%c与%s与%d
// %s 指向内存里面的内容// %d 指向变量里面的值//%s 读入一个内容int main(void){ char *p = NULL; char buf[100] = "abc"; p = &buf[0]; printf("%c\n", *p); //a printf("%s\n", p); //abc print...
2018-11-01 16:03:01
5904
原创 指针易错点
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int main(void){ char *p = NULL; char buf[] = "abcdef"; printf("p1 = %d\n", ...
2018-11-01 15:19:14
192
原创 p与*p
#include<stdio.h>#include<stdlib.h>#include<string.h>int main(void){ char *p = NULL; char buf[] = "abc"; //buf指向常量区“abc”,拷贝到栈区buf,编译器检测到是数组,地址0x11,//注意这里没有指向关系 print...
2018-11-01 14:22:16
1345
转载 堆区分析
#include<stdio.h>#include<stdlib.h>#include<string.h>char *get_str2(){ char *tmp = (char *)malloc(100); //首先栈匀tmp分配100个字节在堆区,拿到了0x11地址,指向0x11所指向的内存区域 if (tmp == NULL){...
2018-10-31 10:29:20
287
转载 栈区分析
#include<stdio.h>#include<stdlib.h>#include<string.h>char *get_str(){ char str[] = "abcd"; //把变量str里面的内容拷贝到文字常量区,文字常量区里面的内容拷贝到数组所对应的空间 return str; //返回str里面的内容}int m...
2018-10-31 09:29:03
145
转载 全局区分析
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>char *get_str1(){ char *p = "abcdef1"; //文字常量区 return p;}char *get_str2(){ ...
2018-10-30 14:30:45
242
转载 给类型起别名
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>typedef unsigned int u32;//typedef和结构体结合使用struct MyStruct{ int a; int b;};...
2018-10-30 11:45:19
408
转载 给类型起别名
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>typedef unsigned int u32;//typedef和结构体结合使用struct MyStruct{ int a; int b;};...
2018-10-30 11:34:38
370
转载 数据类型本质
#include <stdio.h>#include <stdlib.h>#include <string.h>int main(void){ int a; //告诉编译器,分配 4个字节 int b[10]; //告诉编译器,分配 4 * 10 个字节 /*类型的本质:固定内存块大小别名 可以...
2018-10-30 09:52:36
226
转载 如果数组作为函数参数,数组形参退化为指针
//如果数组作为函数参数,数组形参退化为指针//void print_array(int a[1], int n)//void print_array(int a[], int n)//如果数组作为函数参数,数组形参退化为指针//void print_array(int a[1], int n)//void print_array(int a[], int n)void print_...
2018-10-29 14:48:27
550
转载 选择法排序
#include<stdio.h>#include<stdlib.h>#include<string.h>int main(void){ int a[] = { 1, 3, 4, 22, 9, 8 }; int n; int j = 0; int tmp = 0; n = sizeof(a) / sizeof(a...
2018-10-29 13:47:28
788
原创 android sdk 离线下载安装与配置(全)
android sdk在线下载真的很操蛋。尤其对于初学者来说。今天,笔者简单的介绍下,如何离线下载与安装android sdk。(系统要求:64位操作系统)1 首先下载sdk manager 。http://www.cr173.com/soft/71786.html 2 配置sdk manager, 先下载jdk1.7版本以上,配置path。3 配置环境变量path,笔者是win10操作系统。w...
2018-02-08 13:59:08
11910
转载 关于Visual Studio 2013中strcpy函数的使用报错
加上这句话 #pragma warning(disable : 4996)
2017-12-28 10:35:26
464
1
转载 指针铁律专题
铁律1:指针是一种数据类型 1) 指针也是一种变量,占有内存空间,用来保存内存地址测试指针变量占有内存空间大小2)*p操作内存在指针声明时,*号表示所声明的变量为指针在指针使用时,*号表示 操作 指针所指向的内存空间中的值*p相当于通过地址(p变量的值)找到一块内存;然后操作内存*p放在等号的左边赋值(给内存赋值)*p放在等号的右边取值(从内存获取值)3)
2017-12-27 20:41:42
461
转载 数组做函数推演
//把数组当做函数参数的话的时候会退化为指针 int printfArray(int a[]){int i = 0;printf("排序之前\n ");for (i=0; i{printf("%d ", a[i]);}return 0;}
2017-12-27 13:45:17
199
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人