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

  • SEARCH
  • Home
  • 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 7623889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:49:13+00:00 2026-05-31T04:49:13+00:00

If array sizes can only be a constant value than what does char d_name[…]

  • 0

If array sizes can only be a constant value than what does

   char d_name[...] 

mean?

Actually, there is a struct dirent declared in dirent.h file. its declaration is as under:

struct dirent{
  ....
  ino_t d_ino;
  char d_name[...];
  ...
  };

It is used to read directory contents one at a time i.e. inode numbers and filenames etc…

I mean what is the max size of such an array and how much space is statically allocated in the memory once such an array is defined? Is such a definition portable?

  • 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-31T04:49:15+00:00Added an answer on May 31, 2026 at 4:49 am

    Assuming it’s from struct linux_dirent, it’s actually char d_name[] :

    struct linux_dirent {
        unsigned long  d_ino;     /* Inode number */
        unsigned long  d_off;     /* Offset to next linux_dirent */
        unsigned short d_reclen;  /* Length of this linux_dirent */
        char           d_name[];  /* Filename (null-terminated) */
    }
    

    It’s called a flexible array member, using malloc you can allocate more memory to the struct giving d_name a variable size.

    EDIT

    The text the OP is quoting:

    Directory entries are represented by a struct dirent

    struct dirent {
        ...
        ino_t d_ino;            /* XSI extension --- see text */
        char  d_name[...];      /* See text on the size of this array */
    ...
    };
    

    With the ... the authors signals the size isn’t fixed per standard. Each implementation must choose a fixed size, for example Linux chooses 256. But it’s not valid code.

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

Sidebar

Related Questions

I (think I) understand that you can only retrieve the size of an array
I have an array, size can be up to 10000. It holds only 1/2/3/4.
I have an array of RGB values, whose size I can guarantee to match
In C# 2008, what is the Maximum Size that an Array can hold?
It seems like g++ ignores difference in array sizes when passing arrays as arguments.
if an array of size n has only 3 values 0 ,1 and 2
I currently have an enquiry submission form that can only be completed by registered
I heard from someone that the maximum array size in .NET is 4 GB?
I was wondering if it is possible to declare an array (size not known
I come from a php background and in php, there is an array_size() function

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.