设为首页 加入收藏

TOP

c++读取ini的Section节名
2019-08-23 00:37:06 】 浏览:28
Tags:读取 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;
}

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇php的TS和NTS的区别 下一篇1元云购网站建设,一元云购网站制..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目