Can';无法在Visual Studio Express中使用简单的ifstream 我正在学习C++,我正在学习。我遇到了麻烦,因为我的测试应用程序显然无法在VisualStudioExpress 2012中运行。这是我的密码: // ConsoleApp03.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <fstream> #include <string> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { ifstream file_reader; file_reader.open("C:\temp.txt"); // Test to see if the file was opened if (!file_reader.is_open() ) { cout << "Could not open file!" << endl; return 255; } string line; // Read the entire file and display it to the user; while (getline(file_reader,line)) { cout << line << endl; } // Close the file file_reader.close(); return 0; }
这可能会也可能不会解决您的问题,但是Can';无法在Visual Studio Express中使用简单的ifstream 我正在学习C++,我正在学习。我遇到了麻烦,因为我的测试应用程序显然无法在VisualStudioExpress 2012中运行。这是我的密码: // ConsoleApp03.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <fstream> #include <string> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { ifstream file_reader; file_reader.open("C:\temp.txt"); // Test to see if the file was opened if (!file_reader.is_open() ) { cout << "Could not open file!" << endl; return 255; } string line; // Read the entire file and display it to the user; while (getline(file_reader,line)) { cout << line << endl; } // Close the file file_reader.close(); return 0; },c++,visual-studio-2012,ifstream,C++,Visual Studio 2012,Ifstream,这可能会也可能不会解决您的问题,但是\后跟char是一个转义序列。所以你的文件路径实际上是无效的。试一试 file_reader.open("C:\\temp.txt"); \t实际上是指选项卡。请参阅。这可能会解决问题,也可能不会解决问题,但是\后跟char是一个转义序列。所以你的文件路径实际上是无效的。试一试 file_reader.open("C:\\temp.txt"); \t实际上是指选项卡。请参阅。这可能会解决问题,也可能不会解决问题,但是\后跟char是一个转义序列。所以你的文
\
后跟char是一个转义序列。所以你的文件路径实际上是无效的。试一试
file_reader.open("C:\\temp.txt");
\t
实际上是指选项卡。请参阅。这可能会解决问题,也可能不会解决问题,但是\
后跟char是一个转义序列。所以你的文件路径实际上是无效的。试一试
file_reader.open("C:\\temp.txt");
\t
实际上是指选项卡。请参阅。这可能会解决问题,也可能不会解决问题,但是\
后跟char是一个转义序列。所以你的文件路径实际上是无效的。试一试
file_reader.open("C:\\temp.txt");
\t
实际上是指选项卡。请参阅。这可能会解决问题,也可能不会解决问题,但是\
后跟char是一个转义序列。所以你的文件路径实际上是无效的。试一试
file_reader.open("C:\\temp.txt");
\t
实际上是指选项卡。请参阅。尝试文件读取器。打开(“C:\\temp.txt”)代码>或文件读取器打开(“C:/temp.txt”)代码>使用双反斜杠有效。这是一种转义,不是吗?因为它通常用于指示特殊字符,例如'\n'
,要在字符串文本中指定反斜杠字符本身,您需要使用'\\'
。请尝试文件读取器。打开(“C:\\temp.txt”)代码>或文件读取器打开(“C:/temp.txt”)代码>使用双反斜杠有效。这是一种转义,不是吗?因为它通常用于指示特殊字符,例如'\n'
,要在字符串文本中指定反斜杠字符本身,您需要使用'\\'
。请尝试文件读取器。打开(“C:\\temp.txt”)代码>或文件读取器打开(“C:/temp.txt”)代码>使用双反斜杠有效。这是一种转义,不是吗?因为它通常用于指示特殊字符,例如'\n'
,要在字符串文本中指定反斜杠字符本身,您需要使用'\\'
。请尝试文件读取器。打开(“C:\\temp.txt”)代码>或文件读取器打开(“C:/temp.txt”)代码>使用双反斜杠有效。这是一种转义,不是吗?因为它通常用于指示特殊字符,例如'\n'
,要在字符串文本中指定反斜杠字符本身,需要使用'\\'
。