永发信息网

c++中如何提取出一个字符串中的几个字符?

答案:2  悬赏:50  手机版
解决时间 2021-03-05 03:24
  • 提问者网友:锁深秋
  • 2021-03-04 05:32
c++中如何提取出一个字符串中的几个字符?
最佳答案
  • 五星知识达人网友:像个废品
  • 2021-03-04 06:27
string str="abdese";

char ch = str[3];

string s("What we have here is a failure to communicate");

string sub = s.substr(21);

cout << "The original string is " << s << endl;
cout << "The substring is " << sub << endl;

displays

The original string is What we have here is a failure to communicate
The substring is a failure to communicate
全部回答
  • 1楼网友:像个废品
  • 2021-03-04 07:12
#include
void main()
{
char *str = "abdese";
char e = str[3];
printf("%c", e);
}
字符串可以当数组用。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯