- 博客(12)
- 收藏
- 关注
原创 安卓Room框架初使用
安卓Room框架初使用Room框架介绍Database(数据库)Entity:表示数据库中的表。表的复杂写法:DAO:包含用于访问数据库的方法。具体使用(附Demo)添加依赖数据库的建立数据库的升级表结构的修改Entity代码Dao代码表的增删改查操作执行效果总结Room框架介绍Room在·SQLite上提供了抽象层,以便于更加流畅的访问数据库,对数据库进行操作。主要由Database,Entity,Dao这三部分组成:Database(数据库)包含数据库持有者,并作为应用已保留的持久关系型数据的底
2020-05-13 17:08:40 1635 1
原创 Linux链接相关知识
链接首先得知道链接到底是做什么的:链接是将各种代码和数据片段收集并组合成为一个单一文件的过程,这个文件可被加载(复制)到内存并执行。这个步骤在什么时候执行:可执行于编译(源代码翻译成机器代码)时可执行于加载时(程序被加载器加载到内存并执行时)可执行于运行时(由应用程序来执行)一个C源程序到可执行文件的过程一个C源程序可以被执行,得经过下面四个步骤:预处理,调用语言预处理...
2019-12-05 17:28:00 109
原创 几个fork程序的解释
第一个题(经典面试题)#include <stdio.h>#include <sys/types.h>#include <unistd.h> int main(void){ int i; for(i=0; i<2; i++){ fork(); printf("-"); } return 0;}...
2019-12-03 20:08:12 836
原创 关于Linux I/O的相关程序
第一个程序#include "csapp.h"int main(int argc, char *argv[]){ int fd1, fd2, fd3; char c1, c2, c3; char *fname = argv[1]; fd1 = Open(fname, O_RDONLY, 0); fd2 = Open(fname, O_RDONLY, 0...
2019-12-01 14:25:37 124 1
原创 关于C语言中一些类型变量在计算机存储的学习
我们都知道char型变量占一个字节,int型占用4个字节,long占用8个字节,double型变量占8个字节,那么这些变量和指针在计算机中存储在哪个地址单元呢?#include <stdio.h>/* $end show-bytes */#include <stdlib.h>#include <string.h>/* $begin show-bytes...
2019-05-28 22:47:47 171
原创 关于gets()函数的弊端
当我们要对数组进行输入一串字符时,我们可能会用scanf()输入,但是很多时候会图方便用gets()函数,但是这个函数是有弊端的,我们就来看这个弊端在哪。/* Demonstration of buffer overflow */#include <stdio.h>#include <stdlib.h>/* Implementation of library fun...
2019-05-28 21:34:47 1031
原创 递归调用的栈溢出
代码如下`:#include <stdio.h>#include <stdlib.h>int recurse(int x) { int a[1<<15]; /* 4 * 2^15 = 128 KiB */ printf("x = %d. a at %p\n", x, a); a[0] = (1<<14)-1;...
2019-05-28 14:08:33 425
原创 一段代码的分析
代码如下:#include <stdlib.h>#include <stdio.h>#include <unistd.h>static void show_pointer(void *p, char *descr) { // printf("Pointer for %s at %p\n", descr, p); printf("%...
2019-05-27 23:32:23 301
原创 关于数组的越界问题
关于数组的越界问题代码如下:#include <stdio.h>#include <stdlib.h>typedef struct { int a[2]; double d;} struct_t;double fun(int i) { volatile struct_t s; s.d = 3.14; s.a[i] = 10...
2019-05-27 22:15:48 876
原创 浮点数相加的舍入问题
#include <stdio.h>#include <stdlib.h>#include <string.h>#define BUFSIZE 256int main(int argc, char *argv[]) { char prefix[BUFSIZE]; char next[BUFSIZE]; int i; float s...
2019-05-26 16:17:20 1258 1
原创 C语言strtoul()函数的粗略见解
#include <stdio.h>#include <stdlib.h>int main(int argc, char *argv[]) { int i; for (i = 1; i < argc; i++) { unsigned long dig = strtoul(argv[i], NULL, 16); putchar((char) di...
2019-05-26 15:10:30 466
原创 CSAPP学习之关于两个整数相乘的思考
CSAPP学习之关于两个整数相乘的思考相信大家都知道两个数的平方在数学上一定是大于0的,但是在C语言中就不一定了。代码如下:#include <stdio.h>#include <stdlib.h>int sq(int x) { return x*x;}int main(int argc, char *argv[]) { int i; ...
2019-05-26 14:50:30 306
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人