I have a code below :
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void foo(int *a,int c){
    a=&c;
    cout<<"2-a:"<<*a<<endl;
}
int main()
{
    int *  a;
    int b=3;
    int c=6;
    a=&b;
    cout<<"1-a:"<<*a<<endl;
    foo(a,c);
    cout<<"3-a:"<<*a<<endl;
    return 0;
}
It gives me
1-a:3
2-a:6
3-a:3
Is there any way to write ?
1-a:3
2-a:6
3-a:6 
 
     
     
     
     
     
     
    