0

Having trouble swapping values in C++

#include <iostream> using namespace std; int main() { int a = 5; int b = 9; cout << "a: " << a << endl; cout <<"b: " <<b; return 0; }

20th Dec 2020, 12:38 PM
IronCat
IronCat - avatar
2 odpowiedzi
+ 5
Just use std::swap(a, b) to swap the values of a and b
20th Dec 2020, 12:45 PM
Aaron Eberhardt
Aaron Eberhardt - avatar