有这么一个文件Data.txt 内容如下:
'200 100 0 55 0 78 80 112'
想把它循环读出,中间空格不读。int temp;
CFile file("Data.txt",CFile::modeRead);
DWORD dwFileLen;
dwFileLen = file.GetLength();
char *pbuf=new char[dwFileLen];
pbuf = new char[dwFileLen+1];
pbuf[dwFileLen] = 0;
file.Read(pbuf,dwFileLen); //已经把打开的文件放入到pbuf中如何把pbuf循环读出呢?比如int i=1时,数值temp等于200,比如int i=2时,数值temp等于100等等。
'200 100 0 55 0 78 80 112'
想把它循环读出,中间空格不读。int temp;
CFile file("Data.txt",CFile::modeRead);
DWORD dwFileLen;
dwFileLen = file.GetLength();
char *pbuf=new char[dwFileLen];
pbuf = new char[dwFileLen+1];
pbuf[dwFileLen] = 0;
file.Read(pbuf,dwFileLen); //已经把打开的文件放入到pbuf中如何把pbuf循环读出呢?比如int i=1时,数值temp等于200,比如int i=2时,数值temp等于100等等。
解决方案 »
- 自绘带图标的工具栏为什么图标没有颜色
- vc 多线程操作list 问题?
- 《Windows95程序》这本书过时了吗?
- 关于unicode通用型字符串函数问题:
- 完全端口问题?xml问题?缓存问题?系统问题?,盼望建议!
- CEdit中输入中文字符后,接着输入英文到一行的末尾,所有英文字符都自动换到下一行
- 在线等待:如何取得DOC指针?
- 装了双系统,怎样启动win98
- 用vc++6.0 如何生成浏览器模式下的ACTIVEX控件
- (求助帖)自己学习vc也有一年的时间了,怎么感觉对vc还不是很了解,还不能单独编程
- 安装VC遇到“正在搜索已安装组件”无响应,急!!!
- fatal error C1189: #error
Example/* STRTOK.C: In this program, a loop uses strtok
* to print all the tokens (separated by commas
* or blanks) in the string named "string".
*/#include <string.h>
#include <stdio.h>char string[] = "A string\tof ,,tokens\nand some more tokens";
char seps[] = " ,\t\n";
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 );
}
}
你可以下个二进制读取显示文件的软件(WinHex之类的),通过空格的二进制值去判断拆分数据,如果肯定空格分开的是数据的话,组出一个数据就OK了