C: Why the output of sizeof ( 'a' ) is 2 and not 1 ?
Why is the output of sizeof ( 'a' ) 2 and not 1?
Character constants in C are of type int, hence sizeof ( 'a' ) is equivalent to sizeof ( int ) (i.e., 2.) Hence the output comes out to be 2 bytes.
“Chishiki” is Japanese for “knowledge.” e-chishiki.com aims to bring software developers, information security professionals, IT executives and other IT pros a rich body of knowledge in the form of articles, interviews, tutorials and technical discussions. Our contributors are among the biggest names in the Indian IT industry and include noted authors, educators and practitioners.
Why is the output of sizeof ( 'a' ) 2 and not 1?
Character constants in C are of type int, hence sizeof ( 'a' ) is equivalent to sizeof ( int ) (i.e., 2.) Hence the output comes out to be 2 bytes.
On Sale From April 2008
Let Us C
8th Ed.
C programming classic & best seller. 1 million+ copies sold!
Y. Kanetkar
On Sale From Nolvember 2008
Quest C++ Courseware
12+ hours of instructional audio and animated slides.
Y. Kanetkar Asang Dani
Authors | Articles | Tips | Languages | Information Security | Indian IT Industry | Products | Forums | Newsletters | Contact Us
About Us | Terms of Use | Privacy | Sitemap | Contact Us | Search
Comments
Log in or create a user account to comment.