autodataming的个人博客分享 http://blog.sciencenet.cn/u/autodataming

博文

drugpocket: c++ 命令行getopt boost/program_options.hpp

已有 3095 次阅读 2015-12-15 22:42 |个人分类:Pocket_C++|系统分类:科研笔记

perl中有getopt::long 模块

c++中有program_options模块,

getoptmain.cpp.txt



-------------------

安装也挺简单的,见

www_3fwork_com_b201_001786MYM014322.pdf


只需添加2个路径






这样就可以使用boost了。



-------------------------------------------------------------------
ref:
http://huangws138.blog.163.com/blog/static/587906212011112111913796/
c++ map count、find

#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;

void main()
{
//定义map 对象
map<string,int> word;
//定义指针
map<string,int>::iterator it;
//向word 插入元素 ("a",9)
word.insert (map<string,int>::value_type("a",9));

//查找 键是"a"的元素,返回指向元素的指针。
it=word.find ("a");
//如果元素不存在,指针指向word.end().
if(it!=word.end ())
 cout<<it->second<<endl; //输出元素的值

//查找 键是"a"的元素,
int result=word.count ("a");
//如果键存在返回1,否则返回0
if(result)
 cout<<word["a"]<<endl; //输出元素的值

cout<<endl;
}

------------------------------------------------------------------------------------

variables_map vm;// variables_map 是map的一种。

map 可以只有键,没有值。

--------------------------------------------------




https://wap.sciencenet.cn/blog-950202-943566.html

上一篇:drugpocket: c++ 私有函数 应用场景
下一篇:克隆ssh,不要再输密码
收藏 IP: 202.127.19.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (1 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-3-28 19:10

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部