【发布时间】:2016-06-23 14:33:21
【问题描述】:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream inFile;
inFile.open("test.txt");
int foo;
string sFoo;
inFile >> sFoo;
inFile >> foo;
cout << "the name is " << sFoo << endl;
cout << "the first number is " << foo << endl;
inFile >> foo;
cout << "the second number is " << foo << endl;
cout << "Hello World!";
return 0;
}
我尝试将我的文本文件放在同一个文件夹中。但是,由于某种原因,它无法读取文本文件。请有人告诉我在 macbook 上的代码块中做什么来实现这一点!
【问题讨论】:
标签: c++ macos file-io codeblocks ifstream