2012年4月27日

C语言常用函数

摘要: atoi 头文件: #include <stdlib.h> 功 能: 把字符串转换成整型数. 名字来源:array to integer 的缩写. 原型: int atoi(const char *nptr); 函数说明: 参数nptr字符串,如果第一个非空格字符不存在或者不是数字也不是正负号则返回零,否则开始做类型转换,之后检测到非数字(包括结束符 \0) 字符时停止转换,返回整型数。 阅读全文

posted @ 2012-04-27 21:28 wps712 阅读(148) 评论(0) 推荐(0) 编辑

linux下模块与模块间,模块与内核间共享变量

摘要: Linux symbol export method:[1] If we want export the symbol in a module, just use the EXPORT_SYMBOL(xxxx) in the C or H file. And compile the module by adding the compile flag -DEXPORT_SYMTAB. Then we can use the xxxx in the other module.[2] If we want export some symbol in Kernel that is not in a m 阅读全文

posted @ 2012-04-27 21:06 wps712 阅读(794) 评论(0) 推荐(0) 编辑

2012年4月25日

程序中有游离的...

摘要: 编写linux内核实验时,出现——“程序中有游离的‘\200’”错误,原因在于输入法不同,切换到英文输入法重新输入,可得到正确结果。一般在复制代码时遇到这种问题。 阅读全文

posted @ 2012-04-25 19:40 wps712 阅读(620) 评论(0) 推荐(0) 编辑

2012年4月22日

fgets与fscanf读入一行

摘要: char *fgets(char *s, int n, FILE *stream);int fscanf(FILE *stream, char *format,[argument...]);fgets读入最后的\n,而fscanf不读入。所以在获得字符串长度是,int len = strlen(s)-1;//fgets对人的或者int len = strlen(s);//fscanf 读入的 阅读全文

posted @ 2012-04-22 12:03 wps712 阅读(3772) 评论(0) 推荐(0) 编辑

2012年4月18日

linux互斥操作——信号量

摘要: 简单的互斥操作:#include<stdio.h>#include<unistd.h>#include<stdlib.h>#include<stdlib.h>#include<sys/types.h>#include <sys/ipc.h>#include<sys/sem.h>int p(int sem_id){ struct sembuf sb; sb.sem_num=0; sb.sem_op=-1; sb.sem_flg=SEM_UNDO; if(semop(sem_id,&sb,1)==-1) r 阅读全文

posted @ 2012-04-18 22:48 wps712 阅读(256) 评论(0) 推荐(0) 编辑

2012年4月15日

android模拟器SD卡使用

摘要: 1、启动命令行(Win+R,输入cmd),进入android SDK中tools目录下,(cd 目录名)2、创建sd卡映像,输入》 mksdcard 2048M sdcard.img (大小为2G)3、为模拟器选择sd卡:打开Android SDK and AVD Manager,选择对应模拟器,Edit,在SD Card中选File,选择刚建立的 sdcard.img4、用android调试工具adb管理文件:(adb在tools文件夹或platform-tools文件夹下),进入,运行:adb push 文件名 /sdcard5、打开模拟器,在Dev Tools 里 Media Scann 阅读全文

posted @ 2012-04-15 18:59 wps712 阅读(241) 评论(0) 推荐(0) 编辑

2012年4月14日

自己写的shell程序 多层管道、重定向、后台、命令历史

摘要: #include<stdio.h>#include<stdlib.h>#include<unistd.h>#include<fcntl.h>#include<string.h>#include<stdbool.h>#include<signal.h>#include <readline/readline.h>#include <readline/history.h>//#include<errno.h>//#include<sys/stat.h>#define M 阅读全文

posted @ 2012-04-14 18:45 wps712 阅读(652) 评论(0) 推荐(0) 编辑

键盘上键的ASCII码

摘要: 字母 A 到 Z 和标准数字 0 到 9A(65) B(66) C(67) D(68) E(69) F(70) G(71) H(72) I(73) J(74) K(75) L(76) M(77) N(78) O(79) P(80) Q(81) R(82) S(83) T(84) U (85) V(86) W(87) X(88) Y(89) Z(90) 0(48) 1(49) 2(50) 3(51) 4(52) 5(53) 6(54) 7(55) 8(56) 9(57) 数字键盘上的键数字键盘0(96) 数字键盘1(97) 数字键盘2(98) 数字键盘3(99) 数字键盘4(100) 数字键盘5 阅读全文

posted @ 2012-04-14 10:19 wps712 阅读(4302) 评论(0) 推荐(0) 编辑

实现类似于shell中按“向上”,“向下”箭头的功能————readline库

摘要: [转载] 正确编译使用readline库The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Both Emacs and vi editing modes are available. The Readline library includes additional functions to maintain a list of previously-entered com 阅读全文

posted @ 2012-04-14 09:58 wps712 阅读(1227) 评论(0) 推荐(0) 编辑

open创建文件后,再读取出现Permission denied错误

摘要: 函数 open(char *pathname, int flag, mode_t mode),当flag 指定有O_CREAT并忽略mode参数,在下次打开文件时,可能会提示没有权限之 类的错误原因:这样创建的文件权限是随机的,如果要指定创建的文件权限,就需要填写 mode 参数,这个参数是指定文件权限的,文件的权限分3组9位(rwx rwx rwx--对应用户,用户所在组,其它用户), mode 的值用4位表示,为3每组权限的和值。另外还有一个 umask 函数,这个函数是权限屏蔽,和 mode值 正好相反。 阅读全文

posted @ 2012-04-14 00:53 wps712 阅读(2305) 评论(0) 推荐(0) 编辑

导航