-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.

user2864740
  • 60,010
  • 15
  • 145
  • 220
user144905
  • 11
  • 3

2 Answers2

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.

Nawaz
  • 353,942
  • 115
  • 666
  • 851
0

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

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547