我想将整个文件读入字符串。我正在使用Embarcadero C++ Builder XE。使用C++ Builder项目读取字符串中的文件时出现错误
当我使用我的项目中下面的代码,它给错误:
#include <iostream>
#include <iomanip>
#include <iterator>
#include <fstream>
std::ifstream in(Path);
std::string s((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
[ILINK32 Error] Error: Unresolved external 'std::_Mutex::_Lock()' [ILINK32 Error] Error: Unresolved external 'std::_Mutex::_Unlock()' [ILINK32 Error] Error: Unresolved external 'std::char_traits::eq_int_type(const int&, const int&)' [ILINK32 Error] Error: Unresolved external 'std::char_traits::not_eof(const int&)' [ILINK32 Error] Error: Unresolved external 'std::char_traits::to_char_type(const int&)' [ILINK32 Error] Error: Unresolved external 'std::char_traits::eof()' [ILINK32 Error] Error: Unresolved external 'std::char_traits::to_int_type(const char&)' [ILINK32 Error] Error: Unresolved external 'std::locale::id::operator unsigned int()' [ILINK32 Error] Error: Unresolved external 'std::locale::name() const' [ILINK32 Error] Error: Unresolved external 'std::codecvt_base::codecvt_base(unsigned int)' [ILINK32 Error] Error: Unresolved external 'std::locale::facet::_Incref()' [ILINK32 Error] Error: Unresolved external 'std::ios_base::ios_base()' [ILINK32 Error] Error: Unresolved external 'std::ios_base::getloc() const' [ILINK32 Error] Error: Unresolved external 'std::ctype::_Getcat(std::locale::facet * *, std::locale *)' [ILINK32 Error] Error: Unresolved external 'std::ctype::widen(char) const' [ILINK32 Error] Error: Unresolved external 'std::ios_base::rdstate() const' [ILINK32 Error] Error: Unable to perform link
用于读取文件到String的任何其他解决办法?
检查您的图书馆路径。也许你的标准库有一些配置问题。 – Devolus
@Devolus:Intsand ifstream,在Borland C++,RAD XE Embarcadero IDE中是否有读取文件的文件? –
您的问题不是标准库函数,而是您的设置。作为一个旁注,无论如何你发布的并不是一个合适的C++代码,所以你应该发布一个完整的例子。 – Devolus