配置文件格式是
[JP]
K=2EC156673E 2F4240 5595F6
char str[50];
GetPrivateProfileString("JP", "K",NULL, str, sizeof(str),".\\keydog.ini");
得到str后想将其分成三个字符串
str1=2EC156673E
str2=2F4240
str3=5595F6
第一种方法用MFC 
得有这句#include <afx.h>和包含mfc库 CString sz;
GetPrivateProfileString("JP", "K", NULL, sz.GetBuffer(50), 50, "./keydog.ini");
sz.ReleaseBuffer();
int nPos = 0;
CString sz1, sz2, sz3;
sz1 = sz.Tokenize(" ", nPos);
sz2 = sz.Tokenize(" ", nPos);
sz3 = sz.Tokenize(" ", nPos); 第二种用标准c++
得#include <string> 和using std::string; string str(50, 0);
GetPrivateProfileString("JP", "K", NULL, (char*)str.c_str(), 50, "./keydog.ini");
string sz1, sz2, sz3;
int nBegin = 0, nEnd = str.find(' ', nBegin);
sz1 = str.substr(nBegin, nEnd - nBegin);
nBegin = nEnd + 1, nEnd = str.find(' ', nBegin);
sz2 = str.substr(nBegin, nEnd - nBegin);
nBegin = nEnd + 1, nEnd = str.find(' ', nBegin);
sz3 = str.substr(nBegin, nEnd - nBegin); 第三种纯c吧...
得#include <string.h> char str[50] = {0};
GetPrivateProfileString("JP", "K", NULL, str, sizeof(str),".\\keydog.ini");
char sz1[50] = {0}, sz2[50] = {0}, sz3[50] = {0};
sscanf( str, "%[^' ']", sz1);
sscanf( str + strlen(sz1) + 1, "%[^' ']", sz2);
sscanf( str + + strlen(sz1) + strlen(sz2) + 2, "%[^' ']", sz3); 再给个傻瓜版c代码吧, 因为str1等没有另外给空间, 看你怎么用了
#include <stdio.h>
#include <windows.h> int main()
{
char str[50], *str1, *str2, *str3;
GetPrivateProfileString("JP", "K",NULL, str, sizeof(str),".\\keydog.ini");
str2 = str1 = str;
while( ' ' != *++str2);
*str2++ = 0;
for( str3 = str2; ' ' != *++str3; );
*str3++ = 0; return 0;
}

最新文章

  1. 解决cookie跨域访问
  2. C#:调用webservice时提示对操作的回复消息正文进行反序列化时出错
  3. 利用libpcap打印ip包
  4. 防止SVN冲突,Elipse资源同步介绍
  5. POJ(3468)
  6. 通过PowerShell获取TCP响应(类Telnet)
  7. H5实现拍照并上传
  8. centos设置开机自启动
  9. web.xml常用标签整理(不定期更新)
  10. UC浏览器开发者版调试手机页面
  11. poj 3422 Kaka&#39;s Matrix Travels 费用流
  12. java数据类型,hibernate数据类型,标准sql数据类型之间的对应表
  13. Python实战之正则表达式RE/re学习笔记及简单练习
  14. LeetCode(49)-Valid Parentheses
  15. Linux文件系统的基本结构
  16. codeforces gym #102082C Emergency Evacuation(贪心Orz)
  17. mysql数据表的基本操作
  18. pycharm中代码整体缩进
  19. Oracle分区表常见操作
  20. 基于html5背景图片自适应代码

热门文章

  1. Git 时光穿梭鸡 撤销修改
  2. 安装wepack
  3. 洛谷P1439 排列LCS问题
  4. 洛谷P2759 奇怪的函数
  5. codevs1251 括号
  6. 洛谷P1587 [NOI2016]循环之美
  7. [Xcode 实际操作]七、文件与数据-(3)创建文本文件、属性列表文件、图片文件
  8. JSONPath中的表达式
  9. Ionic中基于js的扩展(指令和服务)来实现各种效果
  10. CodeForces - 361A-Levko and Table (思维)