diff options
author | pankunull <panku_null@proton.me> | 2025-08-14 20:55:44 +0200 |
---|---|---|
committer | pankunull <panku_null@proton.me> | 2025-08-14 20:55:44 +0200 |
commit | ab79618ba19b920b7d55b0bad4d9665a15193bb7 (patch) | |
tree | 76d0b352a5bc5df7a6ed4d64cf44635c7dc31caa /main.c | |
parent | 27552efa93073b5a64dfa1cc82d110e98edb269f (diff) |
added src code
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -0,0 +1,25 @@ +#include <stdio.h> + +// Function that tries to change a number without pointer +void noPointerChange(int num) { + num = 100; // Changes local copy only +} + +// Function that changes a number using pointer +void pointerChange(int *numPtr) { + *numPtr = 100; // Changes original value through pointer +} + +int main() { + int value = 50; + + printf("Before noPointerChange: %d\n", value); + noPointerChange(value); + printf("After noPointerChange: %d\n", value); // value unchanged + + printf("Before pointerChange: %d\n", value); + pointerChange(&value); + printf("After pointerChange: %d\n", value); // value changed + + return 0; +} |