[ C++ ] substr
1/* 2 (C) OOMusou 2008 http://oomusou.cnblogs.com
3
4 Filename : cpp_substr.cpp5 Compiler : Visual C++ 8.06 Description : Demo how to use substr() in C++7 Release : 03/08/2008 1.08 */
9 #include <iostream>
10 #include <string>
11
12 using namespace std;13
14 int main() {15 string s = "Hello World";16 string t = s.substr(6, 5); //from 6 to 6+517 18 cout << t << endl; 19 }
Output : World
3
4 Filename : cpp_substr.cpp5 Compiler : Visual C++ 8.06 Description : Demo how to use substr() in C++7 Release : 03/08/2008 1.08 */
9 #include <iostream>
10 #include <string>
11
12 using namespace std;13
14 int main() {15 string s = "Hello World";16 string t = s.substr(6, 5); //from 6 to 6+517 18 cout << t << endl; 19 }
Output : World
留言
張貼留言