#include <bits/stdc++.h>
using namespace std;
int main()
{
char s1[]="";
char s2[]="abcdefg";
char s3[]="ABCDE";
strncat(s1,s2,);
cout<<s1<<endl;///输出12345abc
strncpy(s1,s3,);
cout<<s1<<endl;///输出ABC45abc
strncpy(s2,s3,);
cout<<s2<<endl;///输出ABCDE
cout<<strncmp(s1,s3,)<<endl;///输出0
char *p=strchr(s1,'B');
if(p)
cout<<p-s1<<","<<*p<<endl;///输出1,B
else
cout<<"Not Found"<<endl;
p=strstr(s1,"45a");
if(p)
cout<<p-s1<<","<<p<<endl;///输出3,45abc
else
cout<<"Not Found"<<endl;
cout<<"strtok usage demo:"<<endl;
char str[]="- This,a sample string,ok.";
p=strtok(str," ,.-");
while(p!=NULL)
{
cout<<p<<endl;
////////////输出
/*
This
a
sample
string
ok */
p=strtok(NULL," ,.-");
}
return ;
}

C++字符串操作库函数的更多相关文章

  1. C语言字符串操作常用库函数

    C语言字符串操作常用库函数 *********************************************************************************** 函数 ...

  2. C关于字符串操作的库函数实现总结

    常用C关于字符串操作的库函数实现: //获取字符串长度 int Strlen(const char* s) { assert(s != NULL); ; while (*s++ != '\0') { ...

  3. 转:C语言字符串操作函数 - strcpy、strcmp、strcat、反转、回文

    转自:C语言字符串操作函数 - strcpy.strcmp.strcat.反转.回文 C++常用库函数atoi,itoa,strcpy,strcmp的实现 作者:jcsu C语言字符串操作函数 1. ...

  4. C语言的本质(22)——C标准库之字符串操作

    编译器.浏览器.Office套件等程序的主要功能都是符号处理,符号处理功能在程序中占相当大的比例,无论多复杂的符号处理都是由各种基本的字符串操作组成的,下面介绍如何用C语言的库函数做字符串初始化.取长 ...

  5. C语言字符串操作函数 - strcpy、strcmp、strcat、反转、回文

    原文:http://www.cnblogs.com/JCSU/articles/1305401.html C语言字符串操作函数 1. 字符串反转 - strRev2. 字符串复制 - strcpy3. ...

  6. 九度OJ 1206:字符串连接 (字符串操作)

    时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:4127 解决:1957 题目描述: 不借用任何字符串库函数实现无冗余地接受两个字符串,然后把它们无冗余的连接起来. 输入: 每一行包括两个 ...

  7. C++字符串操作笔试题第二波

    //1.字符串替换空格:请实现一个函数,把字符串中的每一个空格替换成"%20". //比如输入"we are happy.".则输出"we%20are ...

  8. VC++ 字符串操作学习总结

    vc++中各种字符串(转载) http://www.cnblogs.com/tomin/archive/2008/12/28/1364097.html CString ,BSTR ,LPCTSTR之间 ...

  9. Java中的字符串操作(比较String,StringBuiler和StringBuffer)

    一.前言 刚开始学习Java时,作为只会C语言的小白,就为其中的字符串操作而感到震撼.相比之下,C语言在字节数组中保存一个结尾的\0去表示字符串,想实现字符串拼接,还需要调用strcpy库函数或者自己 ...

随机推荐

  1. GoogleMap-------manifest文件配置

    前言:在使用GoopleMap之前需要配置manifest文件 1.这个可有可无,com.xhm.meishi是项目的包名 <!-- 声明调用这个应用需要的权限 --> <permi ...

  2. hibernate Session一级缓存 应该注意的地方

    Session缓存 Hibernate的一级缓存是由Session提供的,因此它存在于Session的整个生命周期中,当程序调用save()/update()/saveOrupdate()/get() ...

  3. lumen 事件

    今天需要实现日志功能,所有使用了一下lumen的event(事件)和listener(监听) Lumen事件:https://lumen.laravel-china.org/docs/5.3/even ...

  4. hdu 4419 线段树 扫描线 离散化 矩形面积

    //离散化 + 扫描线 + 线段树 //这个线段树跟平常不太一样的地方在于记录了区间两个信息,len[i]表示颜色为i的被覆盖的长度为len[i], num[i]表示颜色i 『完全』覆盖了该区间几层. ...

  5. The Best Hacking Tools

    The Best Hacking Tools Hacking Tools : List of security tools specifically aimed toward security pro ...

  6. SpringBoot自带热加载开发工具

    SpringBoot自带热加载开发工具 maven配置: <!-- SpringBoot自带热加载开发工具 --> <dependency> <groupId>or ...

  7. Error: member names cannot be the same as their enclosing type

    在编译的时候会遇到如下问题:member names cannot be the same as their enclosing type 原因:方法名和类名不能一样,如果一样就是一个构造函数.而构造 ...

  8. 深入C#学习系列一:序列化(Serialize)、反序列化(Deserialize)(转)

    序列化又称串行化,是.NET运行时环境用来支持用户定义类型的流化的机制.其目的是以某种存储形成使自定义对象持久化,或者将这种对象从一个地方传输到另一个地方.    .NET框架提供了两种串行化的方式: ...

  9. You can add an index on a column that can have NULL values if you are using the MyISAM, InnoDB, or MEMORY storage engine.

    w https://dev.mysql.com/doc/refman/5.7/en/create-index.html MySQL :: MySQL 5.7 Reference Manual :: B ...

  10. 整理前端css/js/jq常见问题及解决方法(3)

    jq: 1.prepend(参数);//将参数内容前置再某元素内部; eg: <div id="div1">奇妙能力歌</div> $("#div ...