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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:54:54+00:00 2026-06-08T07:54:54+00:00

Possible Duplicate: determine size of dynamically allocated memory in c I have a struct

  • 0

Possible Duplicate:
determine size of dynamically allocated memory in c

I have a struct in my c code, but this question is also valid for all other types so I will use int instead of struct I created.

int *a = realloc(NULL, 10*sizeof(int) );
printf("%d\n",sizeof(a)); //prints 4, needed to be 40

int b[10];
printf("%d\n",sizeof(b)); //prints 40

My question is this: I am using realloc in my code and I don’t know how I can find the total size of my array. What is the easiest way to do that? Thank you.

  • 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-08T07:54:57+00:00Added an answer on June 8, 2026 at 7:54 am

    Remember that sizeof is evaluated at compile-time (except with VLA, but it’s not your case). Imagine that you take the size of realloc argument as user’s input : it’s impossible to the compiler to know the real allocated size. So it returns the size of the pointer.

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

Sidebar

Related Questions

Possible Duplicate: Determine word size of my processor It is One Interview question today.
Possible Duplicate: In Java, what is the best way to determine the size of
Possible Duplicate: Programming java to determine a symmetrical word am new here, but I
Possible Duplicate: How to determine if a number is a prime with regex? This
Possible Duplicate: How to determine the content size of a UIWebView? Hai Guys, I
Possible Duplicate: In Java, what is the best way to determine the size of
Possible Duplicate: .NET: Determine the type of this class in its static method How
Possible Duplicate: In Java, what is the best way to determine the size of
Possible Duplicate: How do you determine the ideal buffer size when using FileInputStream? When
Possible Duplicate: How to determine the class of a generic type? I have a

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.