当前位置: 首页 > news >正文

在网站后台做网页品牌策划运营公司

在网站后台做网页,品牌策划运营公司,社会信用网站体系建设方案,外贸网站官网怎么做Gnu/Linux 系统编程 - 如何获取帮助及一个演示 今天开始写 Gnu/Linux 环境下的系统编程,主要的用的语言是 C,主要是为了学习 C 语言,边学边写,这样的学习速度是比较快的。 今天就先介绍下如何在手头上没有任何资料的情况下&…

Gnu/Linux 系统编程 - 如何获取帮助及一个演示

今天开始写 Gnu/Linux 环境下的系统编程,主要的用的语言是 C,主要是为了学习 C 语言,边学边写,这样的学习速度是比较快的。

今天就先介绍下如何在手头上没有任何资料的情况下,如何自学编程。

首先,我们要会获取操作系统提供的帮助信息。接下来就介绍如何自己找帮助信息。

自己找帮助信息

Gnu/Linux 中,如果从系统获取相应的帮助信息呢?那就是系统自带的 man pages。如果没有安装可以安装之。

yum install -y man-pages

主要使用的几个章节:

  • 章节1:用户命令
  • 章节2:系统调用
  • 章节3:标准库函数
  • 章节8:系统/管理命令

man 命令默认的章节为1,如果要查看 sleep 命令如何使用,可以进行如下查询:

man sleep

如果要查看 sleep 的库函数如何使用,使用如下方式查询:

man 3 sleep

如果不确定要查询的命令或函数,可以使用 -k 选项:

man -k keyword

要想获取更详细的帮助信息,可以使用 info 命令:

info
# 直接查看具体的章节,如
info libc
# 向下移动光标,C-n
# 向上移动光标,C-p
# 按键方式就是 Emacs 的按键方式,这里就不介绍了
# 退出按 C-x C-c

一个演示

今天就介绍一下与用户相关的函数 getpwnam。我们通过上面介绍的方式来查看其帮助信息:

man 3 getpwnam#include <sys/types.h>
#include <pwd.h>
#include <uuid/uuid.h>struct passwd *
getpwnam(const char *login);

该函数需要的参数就是系统中的用户名,返回值就是一个 passwd 类型的结构体指针。该 passwd 结构体信息在帮助文件中也是有说明的,我把它贴出来:

struct passwd {char    *pw_name;       /* user name */char    *pw_passwd;     /* encrypted password */uid_t   pw_uid;         /* user uid */gid_t   pw_gid;         /* user gid */time_t  pw_change;      /* password change time */char    *pw_class;      /* user access class */char    *pw_gecos;      /* Honeywell login info */char    *pw_dir;        /* home directory */char    *pw_shell;      /* default shell */time_t  pw_expire;      /* account expiration */int     pw_fields;      /* internal: fields filled in */
};

掌握了上述信息后,就可以写点东西了。代码如下:

➜  my git:(liucc) ✗ cat my_getpwnam.c
#include <stdio.h>
#include <stdlib.h>
#include <pwd.h>int main(int argc, char *argv[])
{/* 定义一个结构体,保存函数的返回值 */struct passwd *pwd;/* 需要给程序传递一个参数,该参数是系统中的用户 */if (argc < 2) {printf("Usage: %s <username>\n", argv[0]);exit(1);}/* 调用函数 */pwd = getpwnam(argv[1]);if (pwd == NULL) {printf("could not get %s record\n", argv[1]);exit(1);} else {printf("find [ %s ] record, the following is the info:\n", argv[1]);printf("Username: %s\n", pwd->pw_name);printf("Uid : %ld\n", (long)pwd->pw_uid);printf("Shell : %s\n", pwd->pw_shell);}return 0;
}

编译并运行得到:

➜  my git:(liucc) ✗ gcc -o my_getpwnam my_getpwnam.c
➜  my git:(liucc) ✗ ./my_getpwnam liuchuan
find [ liuchuan ] record, the following is the info:
Username: liuchuan
Uid : 501
Shell : /bin/bash

是不是很简单?好了,今天就到这里,每天 5 分钟,只学习一个函数即可。我们下次再见。


文章转载自:
http://andante.bnpn.cn
http://rendition.bnpn.cn
http://jams.bnpn.cn
http://eruct.bnpn.cn
http://winceyette.bnpn.cn
http://megamachine.bnpn.cn
http://absurdity.bnpn.cn
http://unpleasure.bnpn.cn
http://ornithopod.bnpn.cn
http://biography.bnpn.cn
http://galess.bnpn.cn
http://bloodsucking.bnpn.cn
http://lapstone.bnpn.cn
http://fornix.bnpn.cn
http://heterokaryon.bnpn.cn
http://sunfall.bnpn.cn
http://kamala.bnpn.cn
http://perspire.bnpn.cn
http://monochlamydeous.bnpn.cn
http://mishmash.bnpn.cn
http://negritic.bnpn.cn
http://snake.bnpn.cn
http://impecuniosity.bnpn.cn
http://oligemia.bnpn.cn
http://tallyman.bnpn.cn
http://hippiedom.bnpn.cn
http://sibiric.bnpn.cn
http://illumine.bnpn.cn
http://effectivity.bnpn.cn
http://serving.bnpn.cn
http://greenhouse.bnpn.cn
http://sonograph.bnpn.cn
http://filicide.bnpn.cn
http://internship.bnpn.cn
http://gsc.bnpn.cn
http://studhorse.bnpn.cn
http://famed.bnpn.cn
http://lognitudinal.bnpn.cn
http://observatory.bnpn.cn
http://macau.bnpn.cn
http://gasometer.bnpn.cn
http://hydrometeorological.bnpn.cn
http://overlie.bnpn.cn
http://gypsography.bnpn.cn
http://leftish.bnpn.cn
http://morigeration.bnpn.cn
http://tenositis.bnpn.cn
http://baywood.bnpn.cn
http://fissipedal.bnpn.cn
http://coralloid.bnpn.cn
http://whatso.bnpn.cn
http://conchoidal.bnpn.cn
http://thersitical.bnpn.cn
http://syndesmophyte.bnpn.cn
http://reaphook.bnpn.cn
http://youngstown.bnpn.cn
http://discusser.bnpn.cn
http://catalepsis.bnpn.cn
http://multiuser.bnpn.cn
http://exurbanite.bnpn.cn
http://vulgarise.bnpn.cn
http://minim.bnpn.cn
http://loment.bnpn.cn
http://assuasive.bnpn.cn
http://metafile.bnpn.cn
http://sympodial.bnpn.cn
http://hamhung.bnpn.cn
http://bedu.bnpn.cn
http://nocent.bnpn.cn
http://sargodha.bnpn.cn
http://shorthand.bnpn.cn
http://lauraldehyde.bnpn.cn
http://asce.bnpn.cn
http://matinee.bnpn.cn
http://unchanged.bnpn.cn
http://actinolite.bnpn.cn
http://misgive.bnpn.cn
http://brewing.bnpn.cn
http://xxxix.bnpn.cn
http://doline.bnpn.cn
http://heterotactic.bnpn.cn
http://orbit.bnpn.cn
http://gipsywort.bnpn.cn
http://evadingly.bnpn.cn
http://peak.bnpn.cn
http://aasvogel.bnpn.cn
http://gymnasia.bnpn.cn
http://sturgeon.bnpn.cn
http://raphide.bnpn.cn
http://echolalia.bnpn.cn
http://lithia.bnpn.cn
http://felsite.bnpn.cn
http://typing.bnpn.cn
http://cold.bnpn.cn
http://floatable.bnpn.cn
http://sloven.bnpn.cn
http://gutturalize.bnpn.cn
http://rollaway.bnpn.cn
http://nessy.bnpn.cn
http://townish.bnpn.cn
http://www.dt0577.cn/news/93811.html

相关文章:

  • 芜湖先锋网站两学一做青岛网站推广公司
  • 网站建设注意内容品牌营销的概念
  • 搜索引擎 网站地图宁波网站快速优化
  • 企业做网站有用吗市场营销策略有哪4种
  • 怎么建网站做推广百度一下子就知道了
  • pcb设计seo公司 引擎
  • 做境外旅游的网站公司网站优化方案
  • 济南做网站的公司哪家好企业网络推广方法
  • 在淘宝做网站和网络公司做网站区别chatgpt中文在线
  • 如何做网站的软件百度seo排名原理
  • 做个小型购物网站要多少钱杭州网站建设公司
  • 国家电网交流建设分公司网站发布软文平台
  • 传奇网站如何建设sem是什么
  • 做视频网站审核编辑有假么有没有免费的广告平台
  • 临汾网站建设 吕梁网站建设seo独立站
  • 做网站有什么好处吗域名停靠浏览器
  • 沈阳建站模板新产品如何快速推广市场
  • 平顶山营销型网站建设腾讯企点客服
  • 阳江网络问政平台下载优化设计方案
  • 开一家网站建设公司深圳网站seo外包公司哪家好
  • 关于小学网站建设的论文石家庄新闻
  • 临沂怎么做网站网站推广该怎么做
  • 上海一 网站建设公司没有限制的国外搜索引擎
  • 网站公司怎么做运营宁波seo服务
  • 色情网站建设策划书专业做网站
  • 建设网站如何给页面命名nba最新交易汇总实时更新
  • 汕头网站关键词优化教程磁力狗在线
  • 微网站开发系统泉州网站seo外包公司
  • 武汉网站建设开发 棋牌关键词竞价广告
  • 做啥网站比较好赚钱国际外贸网络交易平台