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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:23:40+00:00 2026-05-23T06:23:40+00:00

Check out this program #include<stdio.h> int main (){ char c=’a’; printf(%d %d, sizeof(c),sizeof(‘a’)); }

  • 0

Check out this program

#include<stdio.h>

int main (){

char c='a';
printf("%d %d", sizeof(c),sizeof('a'));
}

the output is 1 4
I know when we write a statement char c=’a’;

then how does it happen that in space of 1 byte (char c) some thing of 4 bytes (ASCII code) is stored why is there no overflow etc.

  • 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-23T06:23:41+00:00Added an answer on May 23, 2026 at 6:23 am

    First, per ANSI/IEC 9899:1999(E) §6.4.4.4:

     10. An integer character constant has type int. The value of an integer character constant
    containing a single character that maps to a single-byte execution character is the
    numerical value of the representation of the mapped character interpreted as an integer. […]

    §6.5.3.4:

     2. The sizeof operator yields the size (in bytes) of its operand, which may be an
    expression or the parenthesized name of a type. The size is determined from the type of
    the operand. […]

     3. When applied to an operand that has type char, unsigned char, or signed char,
    (or a qualified version thereof) the result is 1. […]

    As you can see, since the type of a character constant is int, for sizeof('a') we get sizeof(int), which is 4 on your platform. However, for sizeof(c), we get the size of a char, which is defined to be 1.

    So why can we assign 'a' to a char?

    §6.5.16.1:

     2. In simple assignment (=), the value of the right operand is converted to the type of the assignment expression and replaces the value stored in the object designated by the left operand.

    So, the int that is 'a' is implicitly converted to a char. There’s an example in there as well, showing explicitly that ints can be implicitly converted to char.

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

Sidebar

Related Questions

I have a simple C++ with Boost like this: #include <boost/algorithm/string.hpp> int main() {
Jus check out this program.Logically it seems fine but its giving 000000000000000000000 for everything
Check out this test: [TestFixture] public class Quick_test { [Test] public void Test() {
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
First check out this code. I seems like it should work for me, but
So this question will get technical – eventually – but first check out Hanselminutes
How do i check out a specific directory from CVS and omit the tree
I want to check out all files in all subdirectories of a specified folder.
If I check out a tagged version of my source code without creating a
I was trying to check out a project from SVN using Eclipse. I tried

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.