C++ String insert()
This function is used to insert a new character, before the character indicated by the position pos.
Consider two strings str1 and str2, pos is the positon. Syntax would be :
str : String object to be inserted in another string object.
pos : It defines the position at which new content is inserted just before the specified position.
subpos : It defines the position of first character in string str which is to be inserted in another string object.
sublen : It defines the number of characters of string str to be inserted in another string object.
n : It determines the number of characters to be inserted.
c : Character value to insert.
Let's see the simple example.
String contains : javat tutorial After insertion, String value is javatpoint tutorial
Let's the simple example of insertion when subpos and sublen are given.
String contains C++ is a language After insertion, String is C++ is a programming language
Let's see the simple example of insertion when number of characters to be inserted are given.
String contains : Maths is favorite subject After insertion, String contains : Maths is my favorite subject
Next TopicC++ Strings
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week