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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:19:45+00:00 2026-06-03T18:19:45+00:00

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

  • 0

Possible Duplicate:
How to find the sizeof(a pointer pointing to an array)
Sizeof an array in the C programming language?

#include<stdio.h>

void doit(char x[10]){
    printf("%d\n", sizeof(x));
}

void main(void){
    char x[10];
    printf("%d\n", sizeof(x));
    doit(x);
}

** I don’t know why my question is removed first time. **
Two outputs here are different. Apparently the first one knows x is an array and second one only knows it a ptr. My question is why compiler knows that in the first case it’s an array instead of a ptr?

  • 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-03T18:19:48+00:00Added an answer on June 3, 2026 at 6:19 pm

    I am no compiler expert but during the compilation phase, the compiler performs something called semantic analysis. During this phase, type checking is done. sizeof is also a compile time operator ( barring VLArrays probably ) and during type checking the compiler determines that in main, x is an array and in doit function it is a pointer.

    Its like, the compiler is the owner of the house and hence it knows the type of its tenants.

    Read about the compilation process on wiki

    • 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 tried
Possible Duplicate: How to find the sizeof( a pointer pointing to an array )
Possible Duplicate: Easiest way to find duplicate values in a JavaScript array Javascript array
Possible Duplicate: How to find a duplicate of length 5 in a single array.
Possible Duplicate: Find integer not occurring twice in an array Accenture interview question -
Possible Duplicate: How to find the kth largest element in an unsorted array of
Possible Duplicate: Is array name a pointer in C? So, I usually declare arrays
Possible Duplicate: std::vector<std::string> to char* array I have to call a c function that
Possible Duplicate: Find object by id in an array of JavaScript objects How to
Possible Duplicate: Find and Replace more than 1 word? I want to use jQuery

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.