
// 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节名全部内容,希望文章能够帮你解决如何用C++读取ini文件中的Section节名所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)