Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C++ Question (very simple) no MFC

Status
Not open for further replies.

lGOOODl

Programmer
Dec 4, 2001
31
DK
Hi,

I was wundering if there is a function simular to the "mid" in Visual Basic. so you can go into text and take a part of the text out. like this:

mid("THIS IS THE TEXT",5,6);

then the program should write:

IS THE

Is there any body there can help! am pretty lost right now and have looked inside the <string.h>, but i could'nt find any helpful function.(I've could have misted one)

Please Help Me
-=<GOOOD>=-
 
You can do it like this:

#include <iostream>
#include <string>
using namespace std;

int main()
{
string sentence =&quot;THIS IS THE TEXT&quot; ;
cout<< (sentence.assign(sentence, 5, 6)) << endl ;
return 0;
}

yes it's prety simple !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top