PDA

Click to See Complete Forum and Search --> : equivalent of vb's Right() or Mid()


markman
Dec 11th, 2001, 02:31 PM
^^^^^^^^ in c++

parksie
Dec 11th, 2001, 02:33 PM
#include <iostream>
#include <string>

using namespace std;

int main() {
string info = "This is some info in a string!";

string other = info.substr(5, 10); // substr(start, length)
cout << other << endl;

return 0;
}You can synthesise Left and Right with intelligent use of substr.

PS: Get the length using .size() :)

kedaman
Dec 12th, 2001, 01:16 AM
for C strings:
strncpy(to,from,length);