StrPtr::operator []( int )

Return the character at the specified index.

Virtual?

No

 

Class

StrPtr

 

Arguments

int x

the index to look in

Returns

char

the character at that index

Notes

This operator does no bounds checking, and can therefore return data from beyond the end of the string.

Example

#include <stdhdrs.h>
#include <strbuf.h>

int main( int argc, char **argv )
{
    StrBuf str1;

    str1.Set( "the quick brown fox jumps over the lazy dog" );

    printf( "%c%c%c%c%c\n", str1[1], str1[2], str1[35], str1[35], str1[12] );

    return 0;
}

Executing the preceding code produces the following output:

hello