On Wed, 24 Aug 2016 09:05:52 +0200, David Brown
<
david...@hesbynett.no> wrote:
>On 23/08/16 21:38, Victor Bazarov wrote:
>> On 8/23/2016 3:28 PM, Scott Lurndal wrote:
>>> Victor Bazarov <v.ba...@comcast.invalid> writes:
>>>> On 8/23/2016 1:05 PM, Joseph Hesse wrote:
>>>>> I have a char x = '8' and want to use this to put the integer 8 into an
>>>>> int variable. I know I can do it this way:
>>>>>
>>>>> char x = '8';
>>>>> int y = x -'0';
>>>>>
>>>>> Is this the C++ 11 way of doing this or is there a better way? Should I
>>>>> put x into a string of length 1 and use atoi?
>>>>
>>>> There is no need for atoi. The C++ character set works the way you
>>>> showed for all decimal digits.
>>>
>>> C++ character set?
>>> [.. blahblah ..]
>>
>> Yes, please see the Standard, [lex.charset]. The first paragraph starts
>> with "The /basic character set/ consists".
>>
>
>Yes, but if you read what it says, it only guarantees that the relevant
>characters '0', '1', etc., are available. It does /not/ guarantee that
>their codes are in ascending order.
Yes it does. Two paragraphs later it states "In both the source and