From b6c596ab490abb423f6246ee5731a9763b4d251d Mon Sep 17 00:00:00 2001 From: mpabi Date: Tue, 26 Mar 2024 09:29:31 +0000 Subject: [PATCH] u --- cpp/_rvmain.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cpp/_rvmain.cpp b/cpp/_rvmain.cpp index aad1ed5..0f70993 100644 --- a/cpp/_rvmain.cpp +++ b/cpp/_rvmain.cpp @@ -5,6 +5,27 @@ //int8_t x = 1, y = 2, z[10]; //int8_t *ip; /* ip to wskaźnik do obiektu typu int */ +void swap_ptr (int8_t *x, int8_t *y) { + + int8_t tmp; + tmp = *x; + *x = *y; + *y = tmp; + +} + +// ----------------------------------------------- + +void swap(int8_t x, int8_t y) { + + int8_t tmp; + tmp = x; + x = y; + y = tmp; + +} + + int main() { // ip = &x; /* ip wskazuje teraz x */ @@ -19,6 +40,9 @@ int main() { *mip = 0; /* x ma teraz wartość 0 */ mip = &mz[0]; /* ip wskazuje teraz z[0] */ + swap (mx, my); + swap_ptr (&mx, &my); + return 1; }