欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > > 文章正文

C++中String类的截取字符串学习笔记,string学习笔记

来源: javaer 分享于  点击 38449 次 点评:168

C++中String类的截取字符串学习笔记,string学习笔记


Java中截取字符串的方法有subString()的方法,可以方便的截取所需要的字符串,下面来学习下C++中截取字符串的方法。

#include <iostream>
#include <string>
#include <stdio.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std; 
int main(int argc, char** argv) {
	string str="The current page will delete.";
	cout <<str.substr(2)<<endl;
	cout <<str.substr(str.find("c",0))<<endl;
	cin.get();
	return 0;
}


头文件#include <stdio.h>是用来C语言打印日志的

substr截取字符串参数是开始截取字符串的小标索引

 

相关文章

    暂无相关文章

用户点评