Posted By

Sadeveloper on 12/26/13


Tagged

String swap c++


Versions (?)

C++ swap strings


 / Published in: C++
 

URL: http://www.softafzar.net

Swap strings in C++

  1. // swap strings
  2. #include <iostream>
  3. #include <string>
  4.  
  5. main ()
  6. {
  7. std::string buyer ("money");
  8. std::string seller ("goods");
  9.  
  10. std::cout << "Before the swap, buyer has " << buyer;
  11. std::cout << " and seller has " << seller << '\n';
  12.  
  13. seller.swap (buyer);
  14.  
  15. std::cout << " After the swap, buyer has " << buyer;
  16. std::cout << " and seller has " << seller << '\n';
  17.  
  18. return 0;
  19. }

Report this snippet  

You need to login to post a comment.