trouble with type casting: element of char array to an integer variable
<p>Here is my attempt at doing a problem in a book I'm trying to learn programming from. The problem wants you to convert height in feet and inches into just inches, by only using 1 cin command, instead of asking for feet and inches individually.</p>

<pre><code>cout &lt;&lt; "Enter height in following format F'I\":";
cin &gt;&gt; height;
feet = (int)height[0];
inches = (int)height[2];

cout &lt;&lt; "feet/height[0]: " &lt;&lt; feet &lt;&lt; "/" &lt;&lt; height[0] &lt;&lt; "\t" &lt;&lt; "inches/height[2]: " &lt;&lt; inches &lt;&lt; "/" &lt;&lt; height[2] &lt;&lt; endl; //to test what went wrong, didn't help me much

cout &lt;&lt; "You are " &lt;&lt; feet * 12 + inches &lt;&lt; " inches tall";
</code></pre>

<p>The output is as follows for an input of 6'8"</p>

<pre><code>Enter height in following format F'I":6'8"
feet/height[0]: 54/6    inches/height[2]: 56/8
You are 704 inches tall
</code></pre>

<p>In my first version of this I had feet = height[0] and inches = height[2] without the cast. From my limited understanding of programming and C++ it seems like its getting the ascii number for 6 and 8 so I used an int cast to try and fix it, but it returned the same results.</p>
