Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointer function #2

Open
FranciscoPark opened this issue Nov 17, 2021 · 0 comments
Open

Pointer function #2

FranciscoPark opened this issue Nov 17, 2021 · 0 comments

Comments

@FranciscoPark
Copy link
Owner

FranciscoPark commented Nov 17, 2021

#include <iostream>

using namespace std;
void swap(int* x, int* y);
int main()
{
    
    int a=1;
    int b=2;
    
    int *pointerA = &a;
    int *pointerB = &b;
    cout << a<< " " << b<<endl;
    swap(pointerA,pointerB);
    
    cout << a << " " << b <<endl;
    
}

void swap(int* x,int* y){
    int temp = *x;
    *x = *y;
    *y = temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant