wafuの技術

技術習得の努力メモです。

C++ 部分文字列の取得

C++で部分文字列の取得

#include <string>
#include <iostream>
using namespace std;

void main(void)
{
    string str1("Hello World");
    cout << "右から3文字:" << str1.substr(0,3) << endl;
    cout << "3文字から6文字まで:" << str1.substr(3,6) << endl;
    cout << "6文字以降:" << str1.substr(6) << endl;
}