C语言
dztdeng
这个作者很懒,什么都没留下…
展开
-
getopt与getopt_long
很多命令行程序中都有这两个文件:getopt.c与getopt_long.c。它们的作用是可以方便的获取命令行的参数。在此转一篇文章,讲述它们的作用。一、getoptgetopt被用来解析命令行选项参数。[cpp] view plain copy print?#include extern char *optarg; //选项的参数指针,存放选项对应的输入参数转载 2017-01-12 18:20:55 · 285 阅读 · 0 评论 -
getopt与getopt_long函数详解
一、getoptgetopt被用来解析命令行选项参数。原型:int getopt(int argc, char * const argv[], const char *optstring);解释:调用一次,返回一个选项。 在命令行选项参数再也检查不到optstring中包含的选项时,返回-1,同时optind储存第一个不包含选项的命令行参数。选项是以短线加一转载 2016-11-09 22:08:21 · 582 阅读 · 0 评论 -
各种常用函数.md
1. void bzero(void *s, int n); 头文件:#include <string.h> 原型: void bzero(void *s, int n); **参数:**s为内存(字符串)指针,n 为需要清零的字节数 用途: 会将参数s 所指的内存区域(或字符串)前n 个字节,全部设为零值。 注意: bzero(void *s, int n) 等价于 memset((vo原创 2016-04-21 11:11:26 · 1069 阅读 · 0 评论 -
函数和变量的存储类型声明.md
变量存储类型auto : 只对属于块的变量有效, 具有自动存储期限, 块作用域并且无链接. auto 从来不明确的指明static : 可用与全局变量, 而不必考虑变量声明的位置. 在块作用域外面时, 说明变量具有内部链接, 而在外部时, 把变量的存储期限从自动的变成了静态的. extern : 可以使几个源文件共享一个变量. 其声明的变量具有静态存储期限, 作用域依赖于变量的声明, reg原创 2016-04-17 22:30:07 · 463 阅读 · 0 评论 -
C语言字符串处理函数总结与实例
1)字符串操作strcpy(p, p1) 复制字符串 strncpy(p, p1, n) 复制指定长度字符串 strcat(p, p1) 附加字符串 strncat(p, p1, n) 附加指定长度字符串 strlen(p) 取字符串长度 strcmp(p, p1) 比较字符串 strcasecmp忽略大小写比较字符串 strncmp(p, p1, n) 比较指定长度字符串转载 2017-06-19 09:06:44 · 485 阅读 · 0 评论 -
字符转换
#include <stdio.h>#include <string.h>int asc2hex(char *s, char *r, int len);int hex2asc(char *s, char *r, int len);int main(int argc, char * argv[]){ char result[128] = {0}; char sou...原创 2018-05-11 01:07:26 · 199 阅读 · 0 评论