如何用C++读取ini文件中的Section节名

little bottle
发布: 2019-04-18 14:43:27
转载
3985 人浏览过

本篇文章主要内容是关于如何用c++读取ini的Section节名,附上代码以及注释,具有一定参考价值,感兴趣的朋友可以了解一下。

// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。//
#include "stdafx.h"#include "iostream"
using namespace std;
const short int max_Section= 20;const short int  MAX_SECTION = 20;
int main(){
//确定ini地址LPCTSTR lpFileName="D:\\documents\\visual studio 2015\\Projects\\ConsoleApplication1\\Release\\mysetting.ini";
char chSectionNames[max_Section] = { 0 };//总的提出来的字符串
char chSection[MAX_SECTION] = { 0 };//存放一个小节名
int i;int pos = 0;
int ret=GetPrivateProfileSectionNames(chSectionNames, max_Section, lpFileName);//获取ini文件Section个数和数据
int m;for (i = 0; i < max_Section; i++)//循环得到Section节名{
if (chSectionNames[i] == 0 && chSectionNames[i + 1] != 0)//判断Section节名是否存在{for ( m = pos; m <= i; m++)
{
chSection[m - pos] = chSectionNames[m];//获取小节名cout << chSection[m - pos] ;}pos = i + 1;CString str;str.Format("%s", chSection);
cout << str << endl;
}}
system("pause");    return 0;}
登录后复制

 相关教程:C++视频教程

以上是如何用C++读取ini文件中的Section节名的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:cnblogs.com
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!