I was writing a c++ code like this:
#include <iostream>
using namespace std;
void swap(int *a, int *b)
{
int *c = NULL;
*c = *a;
*a = *b;
*b = *c;
}
int main()
{
int a, b;
cout << "a, b: ";
cin >> a;
cin >> b;
swap(&a, &b);
cout << a << b;
system("pause");
return 0;
}
But when i compiled, it said :"Unhandled exception...access violation reading... ". What is wrong with my code? Sorry for my bad Engline
Aucun commentaire:
Enregistrer un commentaire