请问哪个大虾知道怎么把雪线上面的数据提取后转换为下面的数据
这是两个txt文件
我自己设想的 是
用一个CStdioFile 对象 用readstring 按行读 到CString
然后再用CString.geta(); 一个个字符的去取要的字符 全部加到一个CString 对象 保存这个方法太苯了 有没好点的 ??
FS 44,1.510,L
XYZ 60337.939,3319.737,10.117
FS 45,1.510,DXR
XYZ 60334.793,3318.262,10.116
FS 46,1.510,G
XYZ 60329.986,3320.308,10.157////////////////////////////////////////
L,44,60337.939,3319.737,10.117
DXR,45,60334.793,3318.262,10.116
G,46,60329.986,3320.308,10.157
WSJ,47,60328.635,3307.202,10.139
WSJ,48,60332.386,3306.178,10.114
DXR,49,60333.697,3303.869,10.095
这是两个txt文件
我自己设想的 是
用一个CStdioFile 对象 用readstring 按行读 到CString
然后再用CString.geta(); 一个个字符的去取要的字符 全部加到一个CString 对象 保存这个方法太苯了 有没好点的 ??
FS 44,1.510,L
XYZ 60337.939,3319.737,10.117
FS 45,1.510,DXR
XYZ 60334.793,3318.262,10.116
FS 46,1.510,G
XYZ 60329.986,3320.308,10.157////////////////////////////////////////
L,44,60337.939,3319.737,10.117
DXR,45,60334.793,3318.262,10.116
G,46,60329.986,3320.308,10.157
WSJ,47,60328.635,3307.202,10.139
WSJ,48,60332.386,3306.178,10.114
DXR,49,60333.697,3303.869,10.095
WSJ,48,60332.386,3306.178,10.114
DXR,49,60333.697,3303.869,10.095
/////////////////////////////////////
这是多的!!??
看上面三行就行了
菜鸟刚学
我没msdn
例:
CString strC=_T("WSJ,47,60328.635,3307.202,10.139");
CString strOutput;
AfxExtractSubString(strC,strOutput,1,','); //按逗号分割
结果:strOutput为47
例:
CString strC=_T("WSJ,47,60328.635,3307.202,10.139");
CString strOutput;
AfxExtractSubString(strC,strOutput,1, ", "); //按逗号分割
结果:strOutput为47
不错,留个记号!!!
void CTest0Dlg::OnButton7()
{
CFile file;
if(file.Open(_T("D:\\2.txt"),CFile::modeRead ))
{
int rt = 0;
TCHAR temp[50];
TCHAR usefull[20];
TCHAR h = '\0';
TCHAR l0 = '\0';
TCHAR l1 = '\0';
TCHAR l2 = '\0';
CString str, str1;
str = " TX TX-AMT \r\n----------\r\n";
str1.GetBufferSetLength(20);
do{
str1.GetBufferSetLength(4);
rt = file.Read(&h,1);
if(h == '0' && l0 == ' ' && l1 == ' ' && l2 == '\n')
{
file.Read(temp,19);
file.Read(usefull, 4);
strncpy(str1.GetBuffer(4), usefull, 4);
str1.ReleaseBuffer();
str += str1;
str1.Empty();
str1.GetBufferSetLength(14);
file.Read(temp,41);
file.Read(usefull, 14);
strncpy(str1.GetBuffer(14), usefull, 14);
str1.ReleaseBuffer();
str += str1;
str1.Empty();
str += "\r\n";
}
l2=l1;
l1=l0;
l0=h;
}while(rt); GetDlgItem(IDC_EDIT1)->SetWindowText(str); }
}试过了,没问题
#include <Afxtempl.h>
void CTest0Dlg::OnButton8()
{
CFile file;
if(file.Open(_T("D:\\4.txt"),CFile::modeRead ))
{
int rt = 0;
int i = 0;
TCHAR temp[50];
TCHAR usefull[20];
TCHAR h = '\0';
TCHAR l0 = '\n';
CString str, str1;
CArray <CString, CString> sa;
sa.Add(CString("L,"));
sa.Add(CString("DXR,"));
sa.Add(CString("G,"));
str1.GetBufferSetLength(20);
do{
rt = file.Read(&h,1);
if(h == 'F' && l0 == '\n')
{
str1.GetBufferSetLength(3);
file.Read(temp,14);
file.Read(usefull, 3);
strncpy(str1.GetBuffer(3), usefull, 3);
str1.ReleaseBuffer();
str += sa.GetAt(i++) + str1;
str1.Empty();
}
else if(h == 'X' && l0 == '\n')
{
str1.GetBufferSetLength(25);
file.Read(temp,13);
file.Read(usefull, 25);
strncpy(str1.GetBuffer(25), usefull, 25);
str1.ReleaseBuffer();
str += str1;
str1.Empty();
str += "\r\n";
}
l0=h;
}while(rt);
file.Close();
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}
}不知前面的字符有没有规律?