Answers for "swap string c++"

C++
3

java array swap

public static void swap(int x, int y, int[] arr) {
  	int temp = arr[x];
  	arr[x] = arr[y];
  	arr[y] = temp;
}
Posted by: Guest on May-14-2020
4

double to string c++

std::ostringstream strs;
strs << dbl;
std::string str = strs.str();
Posted by: Guest on March-25-2020
-1

swap string c++

// swap strings
#include <iostream>
#include <string>

main ()
{
  std::string buyer ("money");
  std::string seller ("goods");

  std::cout << "Before the swap, buyer has " << buyer;
  std::cout << " and seller has " << seller << '\n';

  seller.swap (buyer);

  std::cout << " After the swap, buyer has " << buyer;
  std::cout << " and seller has " << seller << '\n';

  return 0;
}
Posted by: Guest on December-19-2020

Browse Popular Code Answers by Language