Steven Sharp wrote:
>>The following example is shown right before table 3-2 in section 3.7
>>
>> a[0]="h"; // OK same as a[0]="hi";
>>
>>Note: there is actually a typo in the text here
>> // OK same as a[0] = "hi" ) <--- ) should be ;
>>
>>This example is showing the assignment of a string to a single character of
>>a. The "first" character of the string is assigned.
>
>
> That would imply that a select of a single character of a string does not
> behave the same way as an integral type, such as a byte. If that were the
> case, then wouldn't you have to go everywhere else in the LRM that deals
> with integral types and add text about characters of strings too?
When I was looking at the LRM for an answer to Shalom's question I was
beginning to wonder about this as well.
>
> Why is this being defined inconsistently with other assignments in the
> language?
I believe that the reason for this is due to the fact that the string
data type is based upon the C++ Standard Template Library implementation
of its string class. In the STL implementation the leftmost character
has index 0. This is consistent with how C-strings are used.
>
> Steven Sharp
> sharp@cadence.com
>
-- --------------------------------------------------------------------- Neil Korpusik Tel: 408-720-4852 Member of Technical Staff Fax: 408-720-4850 Frontend Technologies - ASICs & Processors (FTAP) Sun Microsystems email: neil.korpusik@sun.com ---------------------------------------------------------------------Received on Fri Oct 15 14:28:37 2004
This archive was generated by hypermail 2.1.8 : Fri Oct 15 2004 - 14:28:40 PDT