随笔分类 - 嵌入式
摘要:链表通过尾部插入 #include<stdio.h> #include<stdlib.h> struct Test { int data; struct Test * next; }; printfLink(struct Test * head) { while(head!=NULL) { prin
阅读全文
摘要:#include<stdio.h> #include<stdlib.h> struct Test { int data; struct Test * next; }; printfLink(struct Test * head) { while(head!=NULL) { printf("%d\n"
阅读全文
摘要:删除链表节点可以分为三种:删除头节点,删除中间节点和删除尾节点 #include<stdio.h> #include<stdlib.h> struct Test { int data; struct Test * next; }; printfLink(struct Test * head) { w
阅读全文
摘要:在链表的前方插入节点 #include<stdio.h> struct Test { int data; struct Test * next; }; printfLink(struct Test * head) { while(head!=NULL) { printf("%d\n",head->d
阅读全文
摘要:在指定数据后面插入节点的案例:在Test结构体(这个结构体的data为2)后面插入一个Test结构体(data=6) #include<stdio.h> struct Test { int data; struct Test * next; }; printfLink(struct Test * h
阅读全文
摘要:链表是一种数据结构,它相对于数组来说十分灵活,它存放着一个数据和指向下一个数据的地址(指针)。 链表和数组的区别在于,数组是连续的,而链表可以是不连续的。 输出结果: 上面是一个简易版本的链表实例。 Test结构体存放着数据和下一个Test结构体的地址,然后初始化三个Test结构体实例,让第一个存放
阅读全文
摘要:首先必须安装VMWare里面的VmWareTool (1)拖拽方式:安装完之后就可以通过拖拽的方式将Windows的文件移到虚拟机里了,同样虚拟机里的也可以拖拽到Windows中。 (2)设置共享文件夹 添加完之后出现Windows里的一个共享文件夹JS,然后点击确定 共享文件夹的文件路径为:/mn
阅读全文
摘要:ls:列出当前文件夹下有哪些文件 ls -a:显示所有文件,包括隐藏的文件和文件夹 pwd:显示在当前哪个文件夹下面 mkdir+新建文件夹名称:新建文件夹 进入文件夹:cd+文件夹名称 cd ..:进入上层文件夹,注意是一个空格加.. Tab键:一般文件名太长,先敲前几个字符,然后按Tab键自动补
阅读全文
摘要:Crtl+Alt+T:调出命令窗口 xrandr:列出分辨率列表 设置窗口的分辨率大小为1280x960:xrandr -s 1280x960 通过命令窗口来执行一段C语言程序: VI工具的使用: (1)vi firstCode.c 创建一个firstCode.c文件 (2)按i进入输入模式,出现I
阅读全文
摘要:有时候同一块内存空间存放类型不同,不同类型的变量共享一块空间。 结构体和共用体的区别: (1)结构体元素有各自单独空间,共用体元素共享空间,空间大小由最大类型确定。 (2)结构体元素互不影响共用体赋值会导致覆盖。 #include<stdio.h> #include<string.h> struct
阅读全文
摘要:#include<stdio.h> #include<string.h> struct Student { char name[32]; int age; int height; int weight; }; int main() { struct Student stu1={"hhh",12,45
阅读全文
摘要:#include<stdio.h> #include<string.h> struct Student { char name[32]; int age; int height; int weight; }; int main() { struct Student Stus[3]={ {"hhh",
阅读全文
摘要:数组只能存放一种类型的数据,而结构体内可以存放不同类型的数据。 #include<stdio.h> #include <string.h> struct Student { char name[32]; int age; int height; int weight; }; int main() {
阅读全文
摘要:#include<stdio.h> #include <string.h> int mystrcmp(char * p1,char * p2) { int ret=0; if(p1!=NULL||p2!=NULL) { while(*p1==*p2) { p1++; p2++; } if(*p1!=
阅读全文
摘要:#include<stdio.h> #include <string.h> //实现字符串拼接 char * mystrcat(char * dest,char * src) { char * bak=dest; if(dest==NULL||src==NULL) { return NULL; }
阅读全文
摘要:自己实现一个字符串的拷贝函数 #include<stdio.h> #include<stdlib.h> #include <string.h> char * mystrcpy(char * dest,char * src) { if(dest==NULL||src==NULL) { return N
阅读全文
摘要:#include<stdio.h> #include<stdlib.h> int main() { // char *p;//定义一个野指针:没有让它指向一个变量的地址 // *p='c';//直接对野指针进行操作,会报错 char *p1; p1=malloc(1);//动态开辟内存 *p1='d
阅读全文
摘要:strlen表示的实际的字符串长度,不会把字符串结束符'\0'计算进去,而sizeof则不是实际的字符串长度,它会把字符串的结束标识符'\0'也包含进去。 #include<stdio.h> int main() { char cdata1[125]="hello"; int len1=strlen
阅读全文
摘要:#include<stdio.h> int main() { char cdata[]={'h','e','l','l','o'}; char cdata2[]="hello"; int len=sizeof(cdata)/sizeof(cdata[0]); printf("cdata长度=%d\n
阅读全文
摘要:字符串:可以理解为是由一串字符组成的数组。 定义一个字符串:char s[]="hello"; #include<stdio.h> int main() { char s[]="hello";//这种方式字符串是不能通过指针被修改的,因为“hello”表示的是常量,如果要修改只能通过下标 char
阅读全文