Warning: file_get_contents(https://whois.pconline.com.cn/jsLabel.jsp?ip=127.0.0.1) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable in D:\wwwroot\huidong\wwwroot\function.inc.php on line 884
CutStr——从原字符串中截取一段位置的字符串 - huidong

huidong

首页 | 会员登录 | 关于争取 2022 寒假做出汇东网 Ver3.0.0 !
搜索文章


// 截取字符串中的某段
// str 原字符串
// pStart 起始截取点的数组下标
// pEnd 终止截取点的数组下标
//
// 处理过后的字符串直接返回到原字符串中
void CutStr(wchar_t str[], int pStart, int pEnd)
{
    // 临时保存截取后的字符串
    wchar_t* wchCutText = new wchar_t[lstrlen(str) + 1];
    wsprintf(wchCutText, L"");

    for (int i = pStart; i < pEnd; i++)
    {
        wsprintf(wchCutText, L"%ls%c", wchCutText, str[i]);
    }

    // 将修改好的字符串复制过去
    lstrcpy(str, wchCutText);

    if (wchCutText != NULL)
    {
        delete[] wchCutText;
        wchCutText = NULL;
    }
}




返回首页


Copyright (C) 2018-2024 huidong