Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit be730e9

Browse files
committed
added split string in cpp
1 parent 286578b commit be730e9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎public/data/cpp.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,27 @@
1414
],
1515
"tags": ["cpp", "array", "reverse", "utility"],
1616
"author": "Vaibhav-kesarwani"
17+
},
18+
{
19+
"title": "Split String",
20+
"description": "Splits a string by a delimiter",
21+
"code": [
22+
"std::vector<std::string> split_string(std::string str, std::string delim) {",
23+
" std::vector<std::string> splits;",
24+
" int i = 0;",
25+
" int j = str.find(delim);",
26+
" int inc = delim.length();",
27+
" while (j != std::string::npos) {",
28+
" splits.push_back(str.substr(i, j - i));",
29+
" i = j + inc;",
30+
" j = str.find(delim, i);",
31+
" }",
32+
" splits.push_back(str.substr(i));",
33+
" return splits;",
34+
"}"
35+
],
36+
"tags": ["cpp", "string", "split", "utility"],
37+
"author": "saminjay"
1738
}
1839
]
1940
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /