C++ equivalent of Python String Slice?

前端 未结 6 1252
灰色年华
灰色年华 2021-01-01 13:30

In python I was able to slice part of a string; in other words just print the characters after a certain position. Is there an equivalent to this in C++?

Python Code

6条回答
  •  青春惊慌失措
    2021-01-01 14:17

    You can do something like this using the string class:

    std::string text = "Apple Pear Orange";
    size_t pos = text.find('Pear');
    

提交回复
热议问题