Liny_@NotePad

沉迷ACG中

【20090904】C++培训日志-ini操作

YOYO posted @ 2009年9月07日 06:39 in 【C/C++】 with tags ini , 1684 阅读

rt。话说这篇日志是17号写的 囧。

//////////////////////////////////////////////////////////////////////////
//	CopyRight(c) 2009, YOYO, All Rights Reserved.
//	Author: LIN YiQian
//	Created: 2009/09/17
//	Describe: INI文件读取练习
//////////////////////////////////////////////////////////////////////////
#include <Windows.h>
#include <iostream>

void main(void)
{
	//	读整数
	UINT nResult = GetPrivateProfileInt("pic", "count", 0, ".//config.ini");
	std::cout << nResult << std::endl;

	//	读文本
	char szStr[256];
	memset(szStr, 0, sizeof(szStr));
	GetPrivateProfileString("string", "Display", "", szStr, sizeof(szStr), ".//config.ini");
	std::cout << szStr << std::endl;

	//	写文本
	WritePrivateProfileString("YOYO", "name", "linyq", ".//config.ini");

	//	写段
	WritePrivateProfileSection("CLASS", "company=tq\0date=20090817\0number=48\0", ".//config.ini");

	//	读取段
	GetPrivateProfileSection("CLASS", szStr, sizeof(szStr), ".//config.ini");
	char* p = szStr;
	while (p != NULL)
	{
		std::cout << p << std::endl;
		p = strtok(p + strlen(p) + 1, "\0");
	}

	system("pause");

	return;
}
  • 无匹配

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter