#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
const int FILENAME_MAX=20;
int main() {
ifstream input;
char name[FILENAME_MAX + 1];
int value;
do {
cout << "Enter the filename (maximum of " << (FILENAME_MAX+1)
<< " characters: ";
cin >> name;
input.open(name);
} while(input.fail() );
while(input >> value) {
int count=1;
cout << "value #" << count << "\t" << value << endl;
count++;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是一段非常简单的代码,用于从文件中读取一些数字.不幸的是我无法编译.在"const int FILENAME_MAX = 20;"行之后/上有一个错误 错误显示"数字常量之前预期的非限定id".
有人可以告诉我我做错了什么吗?
我正在使用Xcode 3.0在Mac OS 10.5.8上进行编译