By Rupam Jha
We know that the string supports functions for comparing and swapping strings. In this tutorial we, will learn how to compare and swap strings in c++
In this tutorial, we will learn how to compare and swap strings in C++.
We know that the string supports functions for comparing and swapping strings.
The compare() function is used to compare either two strings or portions of two strings.
The swap() function is used to swap the contents of two string objects.
Given two strings s1&s2 compare and swap it.
Here we can see the comparison & swapping of two strings.
For using string class, we must include in our program.
Compares the string s1 against s2 and x is assigned 0 if the strings are equal ,a positive number if s1 is lexicographically(means in dictionary order) greater than s2 or a negative number otherwise.
exchanges contents of strings s1 & s2.