Advertisement
Dr4noel

Schimbarea valorii a doua elemente intre ele.(POINTERI)

Dec 7th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. void interschimba(int *c, int *d) {
  5.     int temp;
  6.  
  7.     temp = *c;
  8.     *c = *d;
  9.     *d = temp;
  10.  
  11. }
  12.  
  13.  
  14.  
  15. void main() {
  16.     int a, b;
  17.     int *x, *y;
  18.  
  19.     printf("a= ");
  20.     scanf_s("%d", &a);
  21.  
  22.     printf("b= ");
  23.     scanf_s("%d", &b);
  24.  
  25.     x = &a;
  26.     y = &b;
  27.  
  28.     interschimba(x, y);
  29.  
  30.     printf("a = %d si b = %d", *x, *y);
  31.  
  32.     _getch();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement