C++ 將輸入的字符串中英文大寫字母改成對應小寫字母,並且過濾掉非英文字母字符


#include <stdlib.h>
#include <string.h>
#include <ctype.h>

/*
功能:將輸入的字符串中英文大寫字母改成對應小寫字母,並且過濾掉非英文字母字符
    
輸入:字符串
    
輸出:結果字符串,保證輸出地址有效。
     
返回:0表示成功,其它返回-1
     
*/

int  ProcessString(char * strInput,char *strOutput)
{
    while (*strInput)
    {
        if (isalpha(*strInput))
        {
            char single = *strInput;
            *strOutput = tolower(single);
            strOutput++;            
        }
        strInput++;    
    }    

    return 0;
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM