Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 941859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:10:55+00:00 2026-05-15T22:10:55+00:00

#include <iostream> #include <fstream> #include <cstdlib> using namespace std; const int FILENAME_MAX=20; int main()

  • 0
#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;
}

This is a very simple piece of code for reading some numbers from a file.
Unfortunately I can’t get it to compile. There is an error after/on the line
“const int FILENAME_MAX=20;”
The error says “expected unqualified-id before numeric constant.”

Could someone please tell me what I am doing wrong?


I am compiling on Mac OS 10.5.8 with Xcode 3.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:10:55+00:00Added an answer on May 15, 2026 at 10:10 pm

    FILENAME_MAX is a macro that is defined by the standard library*, and so it is already taken for use as an identifier. When you try to use it as an identifier, it’s actually being replaced during preprocessing to some number. A number is not a valid identifier, so you get an error. (Which is why it’s saying “I was expecting an identifier, not a numeric constant.”)

    Rename it to something else. (Or use std::string, though it seems you aren’t quite there yet.)

    *It is defined by <cstdio>. While you don’t include it directly, other standard library headers are free to include any other standard headers as they see fit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 506k
  • Answers 506k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Look at the ThreadPool, specifically the QueueUserWorkItem method. It's quite… May 16, 2026 at 3:52 pm
  • Editorial Team
    Editorial Team added an answer You cannot do this. By definition, generics are a compile-time… May 16, 2026 at 3:52 pm
  • Editorial Team
    Editorial Team added an answer After coding.mof's reply, I finally did what I wanted. However,… May 16, 2026 at 3:52 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

#include<iostream> #include<fstream> #include<cstdlib> #include<iomanip> using namespace std; int main() { ifstream in_stream; // reads
I have the following code fragment #include <iostream> #include <ostream> #include <vector> using namespace
I have the following code: //Comp454 program 2 #include <iostream> #include <string> #include <fstream>
I can't understand why does this code fail with segfault: #include <cstdlib> #include <iostream>
// Huffman Tree.cpp #include stdafx.h #include <iostream> #include <string>//Necessary to do any string comparisons
I made the following program #include <iostream> #include <typeinfo> template<class T> struct Class {
My question is related to this question. #include<iostream> template< typename T > class T1
Hey all. I've downloaded and moved the Xerces (v3.1.1) source here: /usr/include/xerces and I
I am a beginner, and wrote the following program for fun, to search through
I was making sure I knew how to do the op= and copy constructor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.