![]() |
#2
blueskiner2011-05-11 10:55
|
我用下面的代码能获取txt文件的路径,但是不知把txt中每一列数据存到一个一维数组中,
txt中数据格式为3列数据:
1 1 2
2 1 3
3 1 4
1 2 3
2 2 4
3 2 5
1 3 4
........
怎样才能把这三列数据存到对应的三个一维数组中。
A[]={1,2,3,1,2,3,1......}
B[]={1,1,1,2,2,2,3........}
C[]={2,3,4,3,4,5,4........}
获取txt路径的代码如下:

void CTxtArrayDlg ::OnButton1()
{
// TODO: Add your control notification handler code here
char szFilters[] = "MyType Files (*.txt)|*.txt|All Files (*.*)|*.*||";
CFileDialog fileDlg (TRUE, "txt", "*.txt",OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);
// Display the file dialog. When user clicks OK, fileDlg.DoModal()
// returns IDOK.
if( fileDlg.DoModal()==IDOK )
{
CString pathName = fileDlg.GetPathName();
m_FilePath = pathName;
UpdateData(FALSE);
}
}
{
// TODO: Add your control notification handler code here
char szFilters[] = "MyType Files (*.txt)|*.txt|All Files (*.*)|*.*||";
CFileDialog fileDlg (TRUE, "txt", "*.txt",OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);
// Display the file dialog. When user clicks OK, fileDlg.DoModal()
// returns IDOK.
if( fileDlg.DoModal()==IDOK )
{
CString pathName = fileDlg.GetPathName();
m_FilePath = pathName;
UpdateData(FALSE);
}
}