2
A
回答
7
#include <iostream>
#include <string>
int main(int,char**)
{
std::string x = "HelloHello";
x.erase(x.begin());
std::cout << x << "\n";
return 0;
}
打印
elloHello
+0
什么是这个运算符称为::? – 2013-03-26 15:00:17
+1
@SaraKholusi:这是范围解析运算符。 – 2013-03-26 15:22:17
2
尝试使用SUBSTR()
3
使用erase
std::string str ("HelloHello");
str.erase (0,1); // Removes 1 characters starting at 0.
// ... or
str.erase(str.begin());
3
您应该使用子字符串。第一个参数表示起始位置。第二个参数string::npos
表示您希望新字符串包含从指定起始位置到字符串结尾的所有字符。
std::string shorterString = hellohello.substr(1, std::string::npos);
相关问题
- 1. 从字符串中提取字符串
- 2. 从字符串数组中获取char
- 3. 从字符串中提取
- 4. 从字符串中提取
- 5. 从字符串中提取字符
- 6. 从字符串中提取字符
- 7. 从右侧获取字符串10 char
- 8. 从字符串中提取子串
- 9. 从字符串中提取子串
- 10. 从字符串中提取符号
- 11. 从字符串中提取一个字
- 12. 从字符串中提取数字
- 13. iMacros:从字符串中提取数字
- 14. 从字符串中提取数字
- 15. 从字符串中提取数字
- 16. 从字符串中提取数字? Java
- 17. R - 从字符串中提取数字
- 18. 从字符串中提取数字
- 19. 从字符串中提取2个字
- 20. R:从字符串中提取数字
- 21. 从字符串中提取数字
- 22. Rapidminer从字符串中提取数字
- 23. 从字符串中提取数字
- 24. 从字符串中提取数字javascript
- 25. 从字符串中提取数字
- 26. Oracle:从字符串中提取数字
- 27. 从html字符串中提取数字
- 28. 提取值从字符串
- 29. 仅提取从字符串
- 30. 提取从字符串
是什么类型的字符串? char *或std :: string? – emsr 2013-03-26 14:29:21