online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <string_view> #include <vector> #include <algorithm> size_t split(std::vector<std::string_view>& result, std::string_view in, std::string_view seps) { result.reserve(std::count_if(in.begin(), in.end(), [&](char ch){ return seps.find(ch) != std::string_view::npos; }) + 1); std::string_view::size_type start = 0, end; while ((end = in.find_first_of(seps, start)) != std::string_view::npos) { result.push_back(in.substr(start, end-start)); start = in.find_first_not_of(' ', end+1); } if (start != std::string_view::npos) result.push_back(in.substr(start)); return result.size(); } int main() { std::string_view str = "apple, phone, bread\n keyboard, computer"; std::vector<std::string_view> result; split(result, str, "\n,"); std::cout << "Result:["; if (!result.empty()) { std::cout << "'" << result[0] << "'"; for(size_t i = 1; i < result.size(); ++i) std::cout << ", '" << result[i] << "'"; } std::cout << "]"; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue