<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 2.3 &#8212; Variable sizes and the sizeof operator</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 12:30:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Ascendancy</title>
		<link>http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/comment-page-1/#comment-96753</link>
		<dc:creator>Ascendancy</dc:creator>
		<pubDate>Thu, 29 Dec 2011 08:31:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=43#comment-96753</guid>
		<description>As does mine.</description>
		<content:encoded><![CDATA[<p>As does mine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Integers &#124; 4sharesite</title>
		<link>http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/comment-page-1/#comment-96680</link>
		<dc:creator>Integers &#124; 4sharesite</dc:creator>
		<pubDate>Sun, 18 Dec 2011 12:51:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=43#comment-96680</guid>
		<description>[...] is that they have varying sizes — the larger integers can hold bigger numbers. You can use the sizeof operator to determine how large each type is on your [...]</description>
		<content:encoded><![CDATA[<p>[...] is that they have varying sizes — the larger integers can hold bigger numbers. You can use the sizeof operator to determine how large each type is on your [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jimbo</title>
		<link>http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/comment-page-1/#comment-96582</link>
		<dc:creator>jimbo</dc:creator>
		<pubDate>Fri, 09 Dec 2011 00:20:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=43#comment-96582</guid>
		<description>It&#039;s ok I just worked it out. one bit can store two values i.e a 0 or a 1 i.e 2^1 2*1=2. 2 bits can store 4 different values i.e 2^2 2*2= 4 and 3 bits can store 8 different values i.e 2^3 2*2*2= 8.

One more thing..just wondering what to the nth power means? is it like 2^9 or 2*2*2*2*2*2*2*2*2?  Many thanks in advance.</description>
		<content:encoded><![CDATA[<p>It&#8217;s ok I just worked it out. one bit can store two values i.e a 0 or a 1 i.e 2^1 2*1=2. 2 bits can store 4 different values i.e 2^2 2*2= 4 and 3 bits can store 8 different values i.e 2^3 2*2*2= 8.</p>
<p>One more thing..just wondering what to the nth power means? is it like 2^9 or 2*2*2*2*2*2*2*2*2?  Many thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jimbo</title>
		<link>http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/comment-page-1/#comment-96581</link>
		<dc:creator>jimbo</dc:creator>
		<pubDate>Fri, 09 Dec 2011 00:02:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=43#comment-96581</guid>
		<description>First of all thanks Alex for this amazing tutorial...your awesome!!

I was just wandering if one bit can store a 0 or a 1 so two values and two bits can store 4 different values i.e 0101. How come it says 3 bits can store 8 values i.e 01010101? Surely 3 bits would store 6 different values if 1 bit stores 2 different values. 3*2 = 6. If I am missing the point can someone please try and explain where I am going wrong!?
Many thanks in advance.</description>
		<content:encoded><![CDATA[<p>First of all thanks Alex for this amazing tutorial&#8230;your awesome!!</p>
<p>I was just wandering if one bit can store a 0 or a 1 so two values and two bits can store 4 different values i.e 0101. How come it says 3 bits can store 8 values i.e 01010101? Surely 3 bits would store 6 different values if 1 bit stores 2 different values. 3*2 = 6. If I am missing the point can someone please try and explain where I am going wrong!?<br />
Many thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sanjeev_e</title>
		<link>http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/comment-page-1/#comment-96248</link>
		<dc:creator>sanjeev_e</dc:creator>
		<pubDate>Tue, 01 Nov 2011 07:27:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=43#comment-96248</guid>
		<description>Hi Alex/Members,

Is there any other way to find the size of a variable without using sizeof(operator).

I have seen in some of the websites that the below way we can find the same.

int i = 1; 

size_t size1 = (char*)(&amp;i+1)-(char*)(&amp;i); 

size_t size2 = (int*)(&amp;i+1)-(int*)(&amp;i); 

cout&lt;&lt;size1&lt;&lt;&quot;\t&quot;&lt;&lt;size2&lt;&lt;endl;

Output: 4 1

Why it is varying here by typecasting with different datatypes?

I want to know where it is restricted to use sizeof() operator anywhere? and also whether the above code internally uses sizeof() operator like

size1 = address-diff/sizeof(int); size2 = address-diff/sizeof(char); 

Please clarify.

Thanks,
Sanjeev.</description>
		<content:encoded><![CDATA[<p>Hi Alex/Members,</p>
<p>Is there any other way to find the size of a variable without using sizeof(operator).</p>
<p>I have seen in some of the websites that the below way we can find the same.</p>
<p>int i = 1; </p>
<p>size_t size1 = (char*)(&amp;i+1)-(char*)(&amp;i); </p>
<p>size_t size2 = (int*)(&amp;i+1)-(int*)(&amp;i); </p>
<p>cout&lt;&lt;size1&lt;&lt;&quot;\t&quot;&lt;&lt;size2&lt;&lt;endl;</p>
<p>Output: 4 1</p>
<p>Why it is varying here by typecasting with different datatypes?</p>
<p>I want to know where it is restricted to use sizeof() operator anywhere? and also whether the above code internally uses sizeof() operator like</p>
<p>size1 = address-diff/sizeof(int); size2 = address-diff/sizeof(char); </p>
<p>Please clarify.</p>
<p>Thanks,<br />
Sanjeev.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kostas81</title>
		<link>http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/comment-page-1/#comment-95836</link>
		<dc:creator>Kostas81</dc:creator>
		<pubDate>Sun, 07 Aug 2011 21:10:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=43#comment-95836</guid>
		<description>This page should have a like button! :D</description>
		<content:encoded><![CDATA[<p>This page should have a like button! :D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sachinbhanushali</title>
		<link>http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/comment-page-1/#comment-95633</link>
		<dc:creator>sachinbhanushali</dc:creator>
		<pubDate>Sun, 26 Jun 2011 10:52:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=43#comment-95633</guid>
		<description>Visit &lt;a href=&quot;http://www.computereducation.co.cc&quot; title=&quot;computer education The IT Blog&quot; rel=&quot;nofollow&quot;&gt; The IT Blog for eBooks N Solutions with Lots of Hacking Tricks</description>
		<content:encoded><![CDATA[<p>Visit <a href="http://www.computereducation.co.cc" title="computer education The IT Blog" rel="nofollow"> The IT Blog for eBooks N Solutions with Lots of Hacking Tricks</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/comment-page-1/#comment-95438</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Wed, 11 May 2011 13:10:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=43#comment-95438</guid>
		<description>It would be easier to explain the whole thing using the architecture name x86(x86_64) rather than calling them &#039;32-bit&#039; machines. Confuses people.</description>
		<content:encoded><![CDATA[<p>It would be easier to explain the whole thing using the architecture name x86(x86_64) rather than calling them &#8217;32-bit&#8217; machines. Confuses people.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: daksh</title>
		<link>http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/comment-page-1/#comment-95101</link>
		<dc:creator>daksh</dc:creator>
		<pubDate>Sun, 16 Jan 2011 14:44:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=43#comment-95101</guid>
		<description>&lt;code&gt;
bool:           1 bytes
char:           1 bytes
wchar_t:        2 bytes
short:          2 bytes
int:            4 bytes
long:           4 bytes
float:          4 bytes
double:         8 bytes
long double:    8 bytes

Your results may vary if you are using a different type of machine, or a different compiler.
&lt;/code&gt;


I can understand that it depends on the machine.. But how does it depend on the compiler??</description>
		<content:encoded><![CDATA[<p><code><br />
bool:           1 bytes<br />
char:           1 bytes<br />
wchar_t:        2 bytes<br />
short:          2 bytes<br />
int:            4 bytes<br />
long:           4 bytes<br />
float:          4 bytes<br />
double:         8 bytes<br />
long double:    8 bytes</p>
<p>Your results may vary if you are using a different type of machine, or a different compiler.<br />
</code></p>
<p>I can understand that it depends on the machine.. But how does it depend on the compiler??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: prafull.badyal</title>
		<link>http://www.learncpp.com/cpp-tutorial/23-variable-sizes-and-the-sizeof-operator/comment-page-1/#comment-95062</link>
		<dc:creator>prafull.badyal</dc:creator>
		<pubDate>Mon, 20 Dec 2010 17:25:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=43#comment-95062</guid>
		<description>some token error is given at cout statement ...relating end1; in below progg.

1
int x;
2
cout &lt;&lt; &quot;x is &quot; &lt;&lt; sizeof(x) &lt;&lt; &quot; bytes&quot;&lt;&lt;endl;</description>
		<content:encoded><![CDATA[<p>some token error is given at cout statement &#8230;relating end1; in below progg.</p>
<p>1<br />
int x;<br />
2<br />
cout &lt;&lt; &quot;x is &quot; &lt;&lt; sizeof(x) &lt;&lt; &quot; bytes&quot;&lt;&lt;endl;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

