C++를 사용하여 ini 파일에서 섹션 이름을 읽는 방법

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 파일에서 섹션 이름을 읽는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:cnblogs.com
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!