Advertisement
EBobkunov

swap_with_pointers

Mar 10th, 2023
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.24 KB | Source Code | 0 0
  1. #include <stdio.h>
  2.  
  3. void swap (int *a, int *b) {
  4.     int temp;
  5.     temp = *a;
  6.     *a = *b;
  7.     *b = temp;
  8. }
  9.  
  10. int main() {
  11.     int a = 10;
  12.     int b = 20;
  13.     printf("%d %d\n", a, b);
  14.     swap(&a, &b);
  15.     printf("%d %d\n", a, b);
  16. }
Tags: swap pointers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement