C++读取、写入配置文件
来源:互联网 发布:3799游戏盒软件 编辑:程序博客网 时间:2024/05/18 18:03
#include<iostream>#include<string.h>#include <windows.h>using namespace std;#pragma warning(disable:4996)int main() { //写入配置文件 LPTSTR lpPath = new char[MAX_PATH]; strcpy(lpPath, "C://test.ini"); WritePrivateProfileString("LiMing", "Sex", "1111", lpPath); WritePrivateProfileString("LiMing", "Age", "2222", lpPath); WritePrivateProfileString("Fangfang", "Sex", "3333", lpPath); WritePrivateProfileString("Fangfang", "Age", "4444", lpPath); //读取配置文件 LPTSTR LiMingSex = new char[6]; int LiMingAge; LPTSTR FangfangSex = new char[6]; int FangfangAge; strcpy(lpPath, "C://test.ini"); GetPrivateProfileString("LiMing", "Sex", "", LiMingSex, 6, lpPath); LiMingAge = GetPrivateProfileInt("LiMing", "Age", 0, lpPath); cout << LiMingAge << endl; GetPrivateProfileString("Fangfang", "Sex", "", FangfangSex, 6, lpPath); FangfangAge = GetPrivateProfileInt("Fangfang", "Age", 0, lpPath); cout << FangfangAge << endl; delete[] lpPath; system("pause"); //用于防止闪退 }
配置文件格式: [LiMing]
Sex=Man
Age=20
[Fangfang]
Sex=Woman
Age=21
0 0
- C++读取、写入配置文件
- 读取和写入配置文件
- 读取配置文件和写入配置文件
- properties 读取和写入配置文件
- C#读取和写入配置文件
- Properties配置文件读取/写入例子
- VC读取和写入配置文件
- 配置文件读取和写入类
- Java读取/写入Yaml配置文件
- VC配置文件读取和写入
- C#读取与写入配置文件
- c# 使用WINAPI 进行读取写入配置文件
- 可执行文件相关配置文件的读取、写入
- C# 使用WINAPI 进行读取写入配置文件
- 向INI配置文件写入\读取数据
- C#读取写入配置文件Cinfig.ini方法
- java 读取和写入配置文件中的数据
- C#读取及写入配置文件教程
- Junit单元测试细节
- 回调函数
- 【SQL Server】数据操作语言——数据更改功能
- poj-3259-Wormholes
- 构造函数、拷贝构造函数和析构函数
- C++读取、写入配置文件
- Guice基本用法
- php-fallibility
- 1089. Insert or Merge (25)
- js实现瀑布流的两种方法
- nodejs
- tomcat出现Could not load the Tomcat server configuration at 。。异常解决办法
- HTTP协议的简单认识
- Linux多进程