16,472
社区成员
发帖
与我相关
我的任务
分享
#include <vector>
using namespace std;
try
{
CFile file;
file.Open(_T("F:\\11.txt"), CFile::modeRead);
int len = (int)file.GetLength();
char* szBuf = new char[len+1];
memset(szBuf, 0, sizeof(char)*(len+1));
file.Read(szBuf, len);
file.Close();
CString strText(szBuf);
delete szBuf;
LPCTSTR szToken = _T(" ");
int curPos = 0;
CString strToken = _T("");
vector<float> vec;
vec.clear();
while(_T("") != (strToken = strText.Tokenize(szToken, curPos)))
{
float ftmp = (float)_tcstoul(strToken, NULL, 16);
vec.push_back(ftmp);
}
CString strMsg(_T(""));
CString strTmp(_T(""));
for(vector<float>::const_iterator iter = vec.begin(); iter != vec.end(); iter++)
{
strTmp.Format(_T("%f"), *iter);
strMsg += strTmp + _T("\r\n");
}
AfxMessageBox(strMsg);
}
catch (CFileException* e)
{
e->ReportError();
e->Delete();
}
fscanf( stream, "%x ", xx );
->fscanf( stream, "%x ", &xx );
#include <stdio.h>
FILE *stream;
int main( void )
{
float fp;
int xx;
stream = fopen( "fscanf.file", "r" );
if( stream == NULL )
printf( "The file fscanf.out was not opened\n" );
else
{
fscanf( stream, "%x ", xx );
fclose( stream );
}
}