string::Left

Description

Extract the leftmost nCount characters from this string object and returns a copy of the extracted substring. If nCount exceeds the string length, then the entire string is extracted.

Syntax

string Left( int nCount )

Parameters

nCount
[input]The number of characters to extract starting from the leftmost.

Return

A string object containing a copy of the specified range of characters. Note that the returned string object may be empty.

Examples

EX1

void string_Left_ex1()
{
    string str1("abcdef");
    string str2 = str1.Left(3);
    //after extracted,str2 should be "abc"
    printf("the extracted substring is \"%s\"\n", str2);
}

Remark

See Also

string::Right

header to Include

origin.h