victorialais

incremento com ponteiro

Sep 13th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. void incrementa (int *valor) {
  6.    
  7.     (*valor)++;
  8. }
  9.  
  10. int main (){
  11.  
  12. int x = 10;
  13. int *p = &x;
  14.  
  15. cout << x << endl;
  16. incrementa (&x);
  17. cout << x << endl;
  18. return 0;
  19.  
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment