读书人

处理TXT文本文件,该如何解决

发布时间: 2012-04-09 13:41:24 作者: rapoo

处理TXT文本文件
文本文件内容格式如下:
F10 | |Easy7z |Easy7z |"D:\Program Files\Easy7z\Easy7z.exe"
F3 | |ViDown |ViDown |D:\Program Files\ViDown\ViDown.exe
F6 | |san11pk |san11pk |G:\Games\三国志11典藏版\san11pk.exe
F1 | |黄金版TV |黄金版TV |D:\Green\超高清TV\黄金版TV.exe


所需操作:
读入文件并解析以“|”分隔的各列(去除空格、保留双引号),将所需要的列添加到ListCtrl控件中,请问用什么方法实现。

[解决办法]

C/C++ code
#include <string.h>#include <stdio.h>char string[] = "A string|tof ,,tokens||nand some  more tokens";//这里改成读取txt的数组char seps[]   = " |";char *token;void main( void ){   printf( "%s\n\nTokens:\n", string );   /* Establish string and get the first token: */   token = strtok( string, seps );   while( token != NULL )   {      /* While there are tokens in "string" */      printf( " %s\n", token );      //插入代码 显示到控件      /* Get next token: */      token = strtok( NULL, seps );   }} 

读书人网 >C++

热点推荐