C++中讀取文件時路徑標識符“\\”和“//”的區別

#include <fstream>
#include <iostream>
#include <string>
using namespace std;

int main()
{
	ifstream fin;
	fin.open("D://workspace//gt.txt");//經過驗證兩種打開方式均可得到正確輸出
	fin.open("D:\\workspace\\gt.txt");
	string line;
	getline(fin, line);
	cout << line << endl;
	return 0;
}


兩種方式的輸出是一樣的,如下所示:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章