C++ String swap()This function is used to exchange the values of two string objects. SyntaxConsider two strings s1 and s2 , we want to exchange the values of these two string objects. Its syntax would be : ParametersIt contains single parameter, whose value is to be exchanged with that of the string object. Return valueIt does not return any value. Example 1Output: Before swap r contains 10 rupees Before swap m contains 20 rupees After swap r contains 20 rupees After swap m contains 10 rupees In this example, r and m are two string objects containing 10 and 20 rupees respectively. We swap there values by using swap function. After swapping, r contains 20 rupees and m contains 10 rupees. 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