2.2.3.15.27 string::Mid

Description

Extract a substring of length nCount characters from this string object, starting at position nFirst (zero-based).


Extract a substring from this string object. The range is starting at position nFirst (zero-based) and up to the end of string object.

Syntax

string Mid( int nFirst, int nCount )


string Mid( int nFirst )

Parameters

nFirst
[input]The zero-based index of the first character in this string object that is to be included in the extracted substring.
nCount
[input]The number of characters to extract from this string object. If this parameter is not supplied, then the remainder of the string is extracted.


nFirst
[input]The zero-based index of the first character in this string object that is to be included in the extracted substring.

Return

Returns a copy of the extracted substring.

Returns a copy of the extracted substring.

Examples

EX1

void string_Mid_ex1()
{
    string str1("I love summer!");
    string str2 = str1.Mid(2,4);
    //the the extracted substring should be "love"
    printf("the extracted substring is \"%s\" \n", str2);
}


EX2

void string_Mid_ex2()
{
    string str1("I love summer!");
    string str2=str1.Mid(2);
    //the the extracted substring should be "love summer"
    printf("the extracted substring is \"%s\" \n", str2);
}

Remark

See Also

string::Left, string::Right

Header to Include

origin.h