티스토리 뷰

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

vector<string> split(const string &data, const char &delimitor = ' ')
{
    vector<string> result;
    string token;
    stringstream ss(data);

    while (getline(ss, token, delimitor))
    {
        result.push_back(token);
    }

    return result;
}

int main()
{
    vector<string> li = split("hi my name is kim");
    for (int i = 0; i < li.size(); i++)
    {
        cout << li[i] << endl;
    }

    string str = "my name is kim";
    cout << str.substr(0, 4) << endl;
    cout << str.find("name") << endl;
}
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/02   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
글 보관함