online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <vector> #include <string> std::vector<std::string> stringFragmenter(const std::string &inputString, int len, int stepSize) { std::string::const_iterator currentBegin = inputString.begin(); std::string::const_iterator end = inputString.end(); std::string::const_iterator currentPosition = currentBegin; std::vector<std::string> output; std::string pushedString; while(currentPosition != end - len + 1) { currentBegin = currentPosition; std::string::const_iterator currentEnd = currentBegin + len; while(currentBegin != currentEnd) { pushedString+= *currentBegin; ++currentBegin; } output.push_back(pushedString); currentPosition = currentPosition + stepSize; //clear the pushedString for next iteration pushedString.clear(); } return output; } int main() { std::string inputString; std::cin >> inputString; int length;//this denotes the length of string that has to be displayed(stored) at each time std::cin >> length; int stepSize; std::cin >>stepSize;//this denotes the jump size std::vector<std::string> fragmentedString = stringFragmenter(inputString, length, stepSize); //print out the elements of the returned vector so that we can confirm if it contains the correct elements for(const std::string &elem: fragmentedString) { std::cout<<elem<<std::endl; } return 0; }

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