I tried to print out something in the void swap function, but nothing happened. Why is it? It can print out something in the add function or the main function, though. Thank you for your help!
#include <iostream>
using namespace std;
int add(int num1, int num2)
{
int sum = num1 + num2;
cout << "Hello" << endl;
return sum;
}
void swap(int *a, int *b) {
int c = *a;
cout << "Hello" << endl;
*a = *b;
*b = c;
}
int main()
{
int num1 = 10;
int num2 = 20;
cout << "Num1: " << num1 << endl;
cout << "Num2: " << num2 << endl;
swap(num1, num2);
cout << "Num1: " << num1 << endl;
cout << "Num2: " << num2 << endl;
system("pause");
return 0;
}