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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:52:26+00:00 2026-05-30T05:52:26+00:00

Possible Duplicate: Sizeof an array in the C programming language? Why does a C-Array

  • 0

Possible Duplicate:
Sizeof an array in the C programming language?
Why does a C-Array have a wrong sizeof() value when it’s passed to a function?

See the below code and suggest me that what is the difference of "sizeof" keyword when I used like this:

#include<stdio.h>
#include<conio.h>
void show(int ar[]);
void main()
{
    int arr[]={1,2,3,4,5};
    clrscr();
    printf("Length: %d\n",sizeof(arr));
    printf("Length: %d\n",sizeof(arr)/sizeof(int));
    show(arr);
    getch();
}
void show(int ar[])
{
   printf("Length: %d", sizeof(ar));
   printf("Length: %d", sizeof(ar)/sizeof(int));
}

But the output is like this:

Output is:

Length: 10

Length: 5

Length: 2

Length: 1

why I am getting like this; If I want to take the entire data from one array to another array the how can I do?

Suggest me If anyone knows.

  • 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-30T05:52:27+00:00Added an answer on May 30, 2026 at 5:52 am

    Arrays decay to pointers in function calls. It’s not possible to compute the size of an array which is only represented as a pointer in any way, including using sizeof.

    You must add an explicit argument:

    void show(int *data, size_t count);
    

    In the call, you can use sizeof to compute the number of elements, for actual arrays:

    int arr[] = { 1,2,3,4,5 };
    
    show(arr, sizeof arr / sizeof *arr);
    

    Note that sizeof gives you the size in units of char, which is why the division by what is essentially sizeof (int) is needed, or you’d get a way too high value.

    Also note, as a point of interest and cleanliness, that sizeof is not a function. The parentheses are only needed when the argument is a type name, since the argument then is a cast-like expression (e.g. sizeof (int)). You can often get away without naming actual types, by doing sizeof on data instead.

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

Sidebar

Related Questions

Possible Duplicate: Sizeof array passed as parameter Given the function below I understand that
Possible Duplicate: Sizeof an array in the C programming language? I have been working
Possible Duplicate: Sizeof an array in the C programming language? Why is the size
Possible Duplicate: Sizeof array passed as parameter Given the following code, the system I'm
Possible Duplicate: C sizeof a passed array instead of sending the sizeof: void main()
Possible Duplicate: How does this “size of array” template function work? Is there any
Possible Duplicate: std::vector<std::string> to char* array I have to call a c function that
Possible Duplicate: Sizeof array passed as parameter I am being stupid with this sizeof
Possible Duplicate: Array of zero length I have seen such type of code :-
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have

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.