Aim: I am learning pointer of C,now I want to write a function to change the value of a variable .
#include<iostream>
using namespace std;
void change (int * k)
{
if (*k==1) *k==0;
else *k==0;
}
void main()
{
int a=1;
cout<<a<<endl;
change(&a);
cout<<a;
}
I thought that n passing the address of a variable to the function can changes the value of k,but failed . I am eager to figure out the details of the arguement passing.
So, my dear friends, I really need yours help.