新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
用C++讀取ini文件中Section節(jié)名的方法-創(chuàng)新互聯(lián)
這篇文章主要介紹了用C++讀取ini文件中Section節(jié)名的方法,具有一定借鑒價(jià)值,需要的朋友可以參考下。希望大家閱讀完這篇文章后大有收獲。下面讓小編帶著大家一起了解一下。

// ConsoleApplication1.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。//
#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 };//總的提出來(lái)的字符串
char chSection[MAX_SECTION] = { 0 };//存放一個(gè)小節(jié)名
int i;int pos = 0;
int ret=GetPrivateProfileSectionNames(chSectionNames, max_Section, lpFileName);//獲取ini文件Section個(gè)數(shù)和數(shù)據(jù)
int m;for (i = 0; i < max_Section; i++)//循環(huán)得到Section節(jié)名{
if (chSectionNames[i] == 0 && chSectionNames[i + 1] != 0)//判斷Section節(jié)名是否存在{for ( m = pos; m <= i; m++)
{
chSection[m - pos] = chSectionNames[m];//獲取小節(jié)名cout << chSection[m - pos] ;}pos = i + 1;CString str;str.Format("%s", chSection);
cout << str << endl;
}}
system("pause"); return 0;}感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享用C++讀取ini文件中Section節(jié)名的方法內(nèi)容對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,遇到問(wèn)題就找創(chuàng)新互聯(lián),詳細(xì)的解決方法等著你來(lái)學(xué)習(xí)!
本文題目:用C++讀取ini文件中Section節(jié)名的方法-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://www.dlmjj.cn/article/coiopp.html


咨詢(xún)
建站咨詢(xún)
