
linux C
sdvch
dream,vision,courage and hope--create a sunny day
展开
-
gethostbyname()
#include #include #include #include #include #include int main(int argc,char **argv){ char * ptr; char * *pptr; char str[32]; char st[INET6_ADDRSTRLEN]; struct hostent *hptr; while(--argc > 0) { ptr=argv[1]; if((hptr=gethostbyname(ptr)) == NULL) { printf("原创 2010-09-17 00:46:00 · 482 阅读 · 0 评论 -
getopt函数的使用
getopt函数的使用每一天你都在使用大量的命令行程序,是不是感觉那些命令行参数用起来比较方便,他们都是使用getopt来实现的。在Linux下使用getopt写程序是一种比较cool的事情,下面来简单的介绍一下getopt的使用。=== getopt使用 ===在讨论参数处理之前,我们先明确两个概念:选项、选项参数gcc -g -o test test.c我们经常使用上面的命令来编译程序,这里g和o就是选项,其中test就是o的选项参数下面我们来看一下getopt:首先是函数声明:#include ext转载 2010-09-16 20:38:00 · 660 阅读 · 0 评论 -
fgets函数
从流中读一行或指定个字符, 原型是char *fgets(char *s, int n, FILE *stream); 从流中读取n-1个字符,除非读完一行,参数s是来接收字符串,如果成功则返回s的指针,否则返回NULL。 形参注释:*string结果数据的首地址;n-1:一次读入数据块的长度,其默认值为1k,即1024;stream文件指针 例:如果一个文件的当前位置的文本如下 Love ,I Have But ........ 如果用 fgets(str1,转载 2010-09-16 22:11:00 · 672 阅读 · 0 评论 -
网络字节转换inet_aton & inet_ntoa & inet_addr和inet_pton & inet_ntop
inet_aton,inet_addr和inet_ntoa在点分十进制数串(如,“192.168.1.10")与他的32位网络字节二进制值之前转换IPV4地址,有2个比较新的函数inet_pton和inet_ntop,这2个对IPV4和IPV6地址都能处理 #include #include #include int inet_aton(const char *cp, struct in_addr *inp); in_addr_t inet_转载 2010-09-17 01:04:00 · 820 阅读 · 0 评论 -
Ubuntu 12.04增加右键命令:在终端中打开
Ubuntu 12.04增加右键命令:在终端中打开 软件中心:搜索nautilus-open-terminal安装 命令行:sudo apt-get install nautilus-open-terminal原创 2013-08-30 16:44:30 · 1964 阅读 · 0 评论 -
Linux下远程升级脚本
先使用wget将升级文件下载到dcu_update文件夹里,然后使用system(“remote_update.sh”)函数调用执行脚本。 remote_update.sh: [plain] view plaincopy #!bin/sh #此脚本放在dcu文件夹的外面 #杀掉正在运行的dcu进程 pidlist=`ps -ef |grep "dcu.bin" |g转载 2013-11-03 22:00:19 · 2714 阅读 · 0 评论