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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:45:45+00:00 2026-06-14T05:45:45+00:00

Possible Duplicate: How to find the sizeof(a pointer pointing to an array) I know

  • 0

Possible Duplicate:
How to find the sizeof(a pointer pointing to an array)

I know this to find the size of array = sizeof(arr)/sizeof(arr[0])

But I have to implement the following (It’s just a demo):

demo.h

#ifndef __DEMO_H
#define __DEMO_H
void heap_sort(int *);
#endif

demo.c

void heap_sort(int *ptrA)
{
//implementing heap sort 
But here it requires length of array 
}

main.c

#include "demo.h"
int main(void)
{
 int A[10];
 heap_sort(A)
 return 0;
}

FYI .. It’s just a demo.. but here I have to implement it in some other scenarios in which there is restriction that “DON’T CHANGE ANYTHING IN HEADER FILE” which means i can’t change the function signature . Then how to get the array length in demo.c For char it’s easy to get by help of strlen() Isn’t there anything similar to get the length of int,float double types

  • 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-06-14T05:45:46+00:00Added an answer on June 14, 2026 at 5:45 am

    if you can’t change the function signature, then maybe you could pass the size of the array in the first element.

    A[0] = 10;
    heap_sort(A);
    

    Or mark the end of the array with some special value, but I don’t like this one because you’d have to iterate the whole array to find the length and you need to make sure this value is not used in the array:

    A[LENGTH-1] = END//some value;
    
    void array_length(A) {
        while (*A++ != END) {
              length++;
        }
    }
    

    This is just a solution for the restrictions you imposed, what I would normally do, is either pass the size of the array as a second argument, or use a struct for the array:

    struct array_t {
        int *data; //allocate this
        int size;
    };
    

    Note: other horrible solutions include global variables.

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

Sidebar

Related Questions

Possible Duplicate: How to find the sizeof(a pointer pointing to an array) I have
Possible Duplicate: How to find the sizeof(a pointer pointing to an array) Sizeof array
Possible Duplicate: How to find the sizeof(a pointer pointing to an array) Sizeof an
Possible Duplicate: How to find the sizeof(a pointer pointing to an array) I declared
Possible Duplicate: How to find the sizeof( a pointer pointing to an array )
Possible Duplicate: How to find the sizeof(a pointer pointing to an array) I tried
Possible Duplicate: How to find the sizeof(a pointer pointing to an array) When declaring
Possible Duplicate: Find url from string with php I found this code: but 2
Possible Duplicate: Find the smallest unused number in SQL Server I have this table
Possible Duplicate: Easiest way to find duplicate values in a JavaScript array Javascript array

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.