A bit different but you get the idea, here int y is the end position as opposed to the length.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void cut(string t,int x, int y)
{
string build = "";
for ( int i = x; i <= y; i++ )
{
build = build + t[i];
}
cout<<build;
}
int main()
{
string test = "hello";
cut("hello", 2,4);
cin.get();
}
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439