小编Gra*_*tts的帖子

(非常)简单的C++程序中的编译器问题,它从文件中获取数字输入

#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上进行编译

c++ compiler-construction macos file-io constants

2
推荐指数
1
解决办法
956
查看次数

标签 统计

c++ ×1

compiler-construction ×1

constants ×1

file-io ×1

macos ×1