【发布时间】:2013-12-10 18:01:18
【问题描述】:
这是我的 C++ 代码:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
std::ifstream ifs ("strength_classes.txt", std::ifstream::in);
char c = ifs.get();
while (ifs.good()) {
std::cout << c;
c = ifs.get();
}
ifs.close();
return 0;
}
然后我在教程中通过运行以下命令对其进行编译,但它输出错误:
Laptop:Downloads Stu$ c++ -c test.cpp
Laptop:Downloads Stu$ g++ -o test.o
clang: error: no input files
【问题讨论】:
-
如果要使用
std::,则无需使用using namespace std; -
我认为程序无法找到“strength_classes.txt”文件,所以没有提供“strength_classes.txt”,而是提供完整清晰的路径以便编译器找到
-
仍然收到错误:(
-
@LiddleLaLoo 它不能解决问题。这只是与您的编码风格问题无关的评论。
标签: c++ file terminal ifstream