现在的位置: 首页 > 综合 > 正文

字符串__常用字符串函数

2018年04月29日 ⁄ 综合 ⁄ 共 498字 ⁄ 字号 评论关闭
/*
    1.strcpy() 字符串的复制函数
    2.strcat() 字符串的连接函数
    3.strlen() 字符串求长度的函数
    4.strcmp() 字符串比较函数,返回结果只有1和-1
    5.strlwr() 字符串大写转换成小写
    6.strupr() 字符串小写转换成大写
*/

# include<cstdio>
# include<iostream>
# include<cstring>

using namespace std;

int main(void)
{
   // char ch1[] = {"Welcome"};//在对字符串进行操作的时候,常常用一个缺少长度的字符数组来表示
    //char ch2[] = {"to China"};
    //cout<<"The result is:"<<endl<<strcpy(ch1,ch2)<<endl;


    char ch1[] = {"2Welcome"};
    char ch2[] = {"1to China"};
    int num;
    cout<<strcmp(ch1,ch2)<<endl;
    //num = strlen(ch1);
    //cout<<num<<endl;

    //cout<<strcat(ch1,ch2)<<endl;

    return 0;
}

抱歉!评论已关闭.