-4

I have a string as below:

string str="university"; 

and i want to take a portion if this str like "versi" and save it to another string how do i do that?

thanks.

2
  • 2
    This question appears to be off-topic because it is about completely trivial code that even day 1 programmers won't find useful. Commented Sep 5, 2014 at 5:24
  • Why can't you read documentation before asking on forum. It would be faster! Commented Sep 5, 2014 at 5:26

2 Answers 2

3

Use substr() member function:

std::string portion = str.substr(start_index, size); 

Read the online doc for better understanding. Read an introductory book on C++ as well.

Hope that helps.

Sign up to request clarification or add additional context in comments.

Comments

0

Read carefully some documentation about std::string. You want to use the substr member function.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.