Windows10 VS2017 C++ ini解析(使用simpleini头文件)

简介: 版权声明:本文可能为博主原创文章,若标明出处可随便转载。 https://blog.csdn.net/Jailman/article/details/85266402 simpleini项目地址:https://github.com/brofield/simpleini下载,新建项目,并将SimpleIni.h文件通过包含目录的方式加载进来。
版权声明:本文可能为博主原创文章,若标明出处可随便转载。 https://blog.csdn.net/Jailman/article/details/85266402

simpleini项目地址:
https://github.com/brofield/simpleini
下载,新建项目,并将SimpleIni.h文件通过包含目录的方式加载进来。
创建test.ini文件,内容如下:

[server]
root = 10.1.1.1
gc = 10.1.1.2
game = 10.1.1.3

写码:

#include "pch.h"
#include <iostream>
#include <SimpleIni.h>

using namespace std;

int main()
{
	CSimpleIniA ini;
	ini.SetUnicode();
	ini.LoadFile("test.ini");
	const char * pVal = ini.GetValue("server", "game", "default");
	ini.SetValue("server", "game", "10.1.1.5");
	const char * xVal = ini.GetValue("server", "game", "default");
	cout << pVal << endl;
	cout << xVal << endl;

	// save the data back to the file
	int rc = ini.SaveFile("test.ini");
	if (rc < 0) return false;

}

打开test.ini文件会发现game一行内容改变。

目录
相关文章
|
5天前
|
C++
【期末不挂科-C++考前速过系列P6】大二C++实验作业-模板(4道代码题)【解析,注释】
【期末不挂科-C++考前速过系列P6】大二C++实验作业-模板(4道代码题)【解析,注释】
【期末不挂科-C++考前速过系列P6】大二C++实验作业-模板(4道代码题)【解析,注释】
|
5天前
|
Serverless C++ 容器
【期末不挂科-C++考前速过系列P5】大二C++实验作业-多态性(3道代码题)【解析,注释】
【期末不挂科-C++考前速过系列P5】大二C++实验作业-多态性(3道代码题)【解析,注释】
|
5天前
|
C++ 芯片
【期末不挂科-C++考前速过系列P4】大二C++实验作业-继承和派生(3道代码题)【解析,注释】
【期末不挂科-C++考前速过系列P4】大二C++实验作业-继承和派生(3道代码题)【解析,注释】
|
5天前
|
编译器 C++
【期末不挂科-C++考前速过系列P3】大二C++第3次过程考核(20道选择题&12道判断题&2道代码题)【解析,注释】
【期末不挂科-C++考前速过系列P3】大二C++第3次过程考核(20道选择题&12道判断题&2道代码题)【解析,注释】
|
5天前
|
C++
【期末不挂科-C++考前速过系列P2】大二C++第2次过程考核(20道选择题&10道判断题&3道代码题)【解析,注释】
【期末不挂科-C++考前速过系列P2】大二C++第2次过程考核(20道选择题&10道判断题&3道代码题)【解析,注释】
|
3天前
|
Linux 网络安全 Windows
网络安全笔记-day8,DHCP部署_dhcp搭建部署,源码解析
网络安全笔记-day8,DHCP部署_dhcp搭建部署,源码解析
|
4天前
HuggingFace Tranformers 源码解析(4)
HuggingFace Tranformers 源码解析
6 0
|
4天前
HuggingFace Tranformers 源码解析(3)
HuggingFace Tranformers 源码解析
7 0
|
4天前
|
开发工具 git
HuggingFace Tranformers 源码解析(2)
HuggingFace Tranformers 源码解析
7 0
|
4天前
|
并行计算
HuggingFace Tranformers 源码解析(1)
HuggingFace Tranformers 源码解析
9 0

推荐镜像

更多