E D R , A S I H C RSS

포인터 swap

~cpp
#include <iostream>

using namespace std;

void swap(int *a,int *b );

int main()
{
	int a = 1;
	int b = 18;
	cout << "a = " << a << "b = " << b << endl;
	swap(&a, &b);
	cout << "a = " << a << "b = " << b << endl;

	system("pause");
	return 0;


}

void swap(int *a,int *b)
{
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:24
Processing time 0.0235 sec