您当前的位置: 首页 >  c++

qianbo_insist

暂无认证

  • 2浏览

    0关注

    399博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

c++快速读取配置文件

qianbo_insist 发布时间:2021-07-22 07:41:17 ,浏览量:2

配置文件样例

#in.txt #缩放到1280 720 rtsp://127.0.0.1/l.264 1280 720

#开头代表注释,而一行中有三个数据,以空格隔开。分别是rtsp地址,宽度 ,高度。使用c++ fstream的移位符来读取空格后数据。

srcFile >> s.d_width >> s.d_height;
读取文件
std::ifstream srcFile("in.txt", std::ios::in); //以文本模式打开in.txt备读
show me the code
#include 
#include 
#include  
#include 
#include 
typedef struct s_source
{
	std::string v_s;
	int d_width;
	int d_height;
}s_source;
class c_file
{
	std::vector v_sources;
public:
	int func_read()
	{
		std::ifstream srcFile("in.txt", std::ios::in); //以文本模式打开in.txt备读
		if (!srcFile) { //打开失败
			std::cout  s.d_width >> s.d_height;
				v_sources.push_back(s);
			}
		}

		for (auto x : v_sources)
		{
			std::cout             
关注
打赏
1663161521
查看更多评论
0.0670s