Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/148.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ can';t初始化ifstream“;读取字符串“”的字符时出错;_C++_C++11_Ifstream - Fatal编程技术网

C++ can';t初始化ifstream“;读取字符串“”的字符时出错;

C++ can';t初始化ifstream“;读取字符串“”的字符时出错;,c++,c++11,ifstream,C++,C++11,Ifstream,下面给了我一个奇怪的信息: 消息显示在ifstream文本中(悬停时) 路径是完整的windows样式路径,例如:“C:\t.txt” void checkInput(字符串路径) { ifstream文本(路径); // "......" if(text.is_open()) { if(text.good()) ... 全文如下: {_Filebuffer={_Set_eback=0xcccccccc <Error reading characters of string>. _

下面给了我一个奇怪的信息: 消息显示在ifstream文本中(悬停时) 路径是完整的windows样式路径,例如:“C:\t.txt”

void checkInput(字符串路径)
{
ifstream文本(路径);
// "......"
if(text.is_open())
{
if(text.good())
...
全文如下:

{_Filebuffer={_Set_eback=0xcccccccc <Error reading characters of string>.
_Set_egptr=0xcccccccc <Error reading characters of string>. ...} }
std::basic_ifstream<char,std::char_traits<char>> "
{Filebuffer={{u Set\u eback=0xcccc。
_Set_egptr=0xCCCC….}
std::基本\u ifstream“
我尝试使用char*代替string和string.c_str。 不好

谢谢你的回答, 虽然我仍然收到这条消息,但代码似乎仍在运行。 以前我的代码中还有一个错误

我想删除这个,但是知道这个消息不会阻止代码运行可能会有所帮助

  • 如果您使用的路径像您写的“C:\t.txt”一样-这是不正确的。使用时必须使用双反斜杠,如“C:\\t.txt”
  • 如果使用绝对路径,则检查文件是否存在这样的路径
  • 如果您使用相对路径,则它取决于您在何处运行代码:从VS(调试模式)或仅运行可执行文件

  • 显示呼叫站点,至少,以及“路径”中的内容…啊,这似乎是一个,很可能是的重复。您是否错误地使用了相对路径?另外,包括所有需要帮助的信息,是“消息”吗"编译器错误?是否在运行时打印?您是否使用错误获取函数来获取它?我与这个可怜的家伙有相同的问题。这些信息没有帮助。我有正确的绝对路径,具有正确的\\字符,并且文件实际上存在。我也有相同的问题。代码本身在项目中运行得非常好。Bigges永远不要神秘。
    {_Filebuffer={_Set_eback=0xcccccccc <Error reading characters of string>.
    _Set_egptr=0xcccccccc <Error reading characters of string>. ...} }
    std::basic_ifstream<char,std::char_traits<char>> "