Home > Backend Development > C#.Net Tutorial > How to read the Section name in ini file using C++

How to read the Section name in ini file using C++

little bottle
Release: 2019-04-18 14:43:27
forward
4048 people have browsed it

本篇文章主要内容是关于如何用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;}
Copy after login

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

The above is the detailed content of How to read the Section name in ini file using C++. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template