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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:37:30+00:00 2026-05-31T02:37:30+00:00

Possible Duplicate: Sizeof doesn't return the true size of variable in C C ->

  • 0

Possible Duplicate:
Sizeof doesn't return the true size of variable in C
C -> sizeof string is always 8

Sizeof prints out 6 for:

printf("%d\n", sizeof("abcde"));

But it prints out 4 for:

char* str = "abcde";
printf("%d\n", sizeof(str));

Can someone explain why?

  • 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-31T02:37:31+00:00Added an answer on May 31, 2026 at 2:37 am

    The string literal "abcde" is a character array. It is 6 bytes long, including the null terminator.

    A variable of type char* is a pointer to a character. Its size is the size of a pointer, which on 32-bit systems is 4 bytes. sizeof is a compile time operation†, so it only looks at the variable’s static type, which in this case is char*. It has no idea what’s being pointed to.

    † Except in the case of variable-length arrays, a feature introduced in the C99 language standard

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

Sidebar

Related Questions

Possible Duplicate: Sizeof an array in the C programming language? Why is the size
Possible Duplicate: sizeof(int) on x64? The size of IntPtr changes from 4 to 8
Possible Duplicate: Can sizeof return 0 (zero) Is there a legal way to define
Possible Duplicate: C++: What is the size of an object of an empty class?
Possible Duplicate: Why isn’t sizeof for a struct equal to the sum of sizeof
Possible Duplicate: What is faster/prefered memset or for loop to zero out an array
Possible Duplicate: How does delete[] “know” the size of the operand array? Assume i
Possible Duplicate: Sizeof an array in the C programming language? Why does a C-Array
Possible Duplicate: relative font-size of <sub> or <sup> and their descendants in IE I'm
Possible Duplicate: sizeof (int) == sizeof (void*)? I was wondering whether it is guaranteed

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.