C++ String Assign()This functions assigns a new value to the string,replacing all its current contents. SyntaxConsider two strings str1 and str2, Syntax would be : Parametersstr : str is a string object, whose value to be assigned. subpos : It defines the position of the character which is to be copied as a substring. sublen : It determines the number of characters of string to be copied in another string object. n : Number of characters to copy. ch : Character value to be copied n times Return value*this Example 1Let's see simple example. Output: Assigned string is :javatpoint Example 2Let's see simple example when position and length are mentioned in the parameters. Output: programming language Example 3Let's see simple example when n is given. Output: Assigned string is : javatpoint Example 4Let's see simple example when character value is given in a parameter. Output: aaaaaaaaaa Next TopicC++ Strings |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India