代码如下:
CString strFileName = _T("D:\\abc.txt");
if (!PathFileExists(strFileName))
{
return FALSE;
}
CStdioFile file;
if (!file.Open(strFileName, CFile::modeRead))
{
return FALSE;
}
std::vector<CString> vecResult;
CString strValue = _T("");
while(file.ReadString(strValue))
{
vecResult.push_back(strValue);
}
file.Close();
本文介绍了一个使用C++读取指定路径文件内容到向量的具体实现过程。通过检查文件是否存在,打开文件并逐行读取内容,将每一行作为一个元素存入到标准模板库中的向量中。
671

被折叠的 条评论
为什么被折叠?



