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 1096863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:20:38+00:00 2026-05-17T00:20:38+00:00

I have this function: int setIncludes(char *includes[]); I don’t know how many values includes

  • 0

I have this function:

int setIncludes(char *includes[]);

I don’t know how many values includes will take. It may take includes[5], it may take includes[500]. So what function could I use to get the length of includes?

  • 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-17T00:20:39+00:00Added an answer on May 17, 2026 at 12:20 am

    There is none. That’s because arrays will decay to a pointer to the first element when passing to a function.

    You have to either pass the length yourself or use something in the array itself to indicate the size.


    First, the “pass the length” option. Call your function with something like:

    int setIncludes (char *includes[], size_t count) {
        // Length is count.
    }
    :
    char *arr[] = {"Hello,", "my", "name", "is", "Pax."};
    setIncludes (arr, sizeof (arr) / sizeof (*arr));
    setIncludes (arr, 2); // if you don't want to process them all.
    

    A sentinel method uses a special value at the end to indicate no more elements (similar to the \0 at the end of a C char array to indicate a string) and would be something like this:

    int setIncludes (char *includes[]) {
        size_t count = 0;
        while (includes[count] != NULL) count++;
        // Length is count.
    }
    :
    char *arr[] = {"Hello,", "my", "name", "is", "Pax.", NULL};
    setIncludes (arr);
    

    Another method I’ve seen used (mostly for integral arrays) is to use the first item as a length (similar to Rexx stem variables):

    int setIncludes (int includes[]) {
        // Length is includes[0].
        // Only process includes[1] thru includes[includes[0]-1].
    }
    :
    int arr[] = {4,11,22,33,44};
    setIncludes (arr);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function: void func(int a, int b, char s, FILE *fp, int
I have a dll which contains this function: int __stdcall PrnText(char *printtext); In Windows
I have this function: char* ReadBlock(fstream& stream, int size) { char* memblock; memblock =
I have this function: void receive_message(int sock, char buffer[]) { int test = recv(sock,
i have this function char* copy(char* pString,...){ char *vToate; int vLen; va_list vAp; va_start(vAp,pString);
I have this function: char * folderFromPath(char *path) { printf(\nentered folderFromPath\n); char *token[80]; int
I have this function: int firstHeapArray (IntHeapArray h) { if(!emptyHeapArray(h)) return h.array[0]; } It's
I have this function: public bool IsValidProduct(int productTypeId) { bool isValid = false; if
I have this function signature I have to match typedef int (*lua_CFunction) (lua_State *L);//target
I have this user defined function. public partial class UserDefinedFunctions { static int i;

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.