【发布时间】:2012-08-13 14:00:59
【问题描述】:
我想从格式如下的 CString 中提取一个浮点数:(例如提取 22.760348)
Incidence_angle(inc)[deg] :22.760348
基本上我正在读取一个包含一些参数的纯文本文件,并且我想对这些值执行一些计算。我使用 CStdioFile 对象读取文件并使用 readString 方法提取每一行,如下所示:
CStdioFile result(global::resultFile,CFile::modeRead);
while( result.ReadString(tmp) )
{
if(tmp.Find(L"Incidence_angle(inc)[deg]") != -1)
{
//extract value of theeta i here
// this is probably wrong
theeta_i = _tscanf(L"Incidence_angle(inc)[deg] :%f",&theeta_i);
}
}
我尝试使用 scanf,因为我想不出任何其他方式。
如果这个问题看起来非常基本和愚蠢,我深表歉意,但我已经坚持了很长时间,希望得到一些帮助。
编辑:拿出我写的概念证明程序,造成混乱
【问题讨论】:
-
你能出示
theeta_i的声明吗? -
@Andrey - float pixel_spacing=0, line_spacing=0, theeta_i=0;