Created
May 28, 2025 06:58
-
-
Save smarteist/66c74bf003da35d306f20e8ca5a995e6 to your computer and use it in GitHub Desktop.
Revisions
-
smarteist created this gist
May 28, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ #include <stdio.h> int main() { // 1. Declaring a Pointer int *ptr; // Pointer to an integer // 2. Assigning Address to a Pointer int var = 10; ptr = &var; // ptr now holds the address of var // 3. Dereferencing a Pointer int value = *ptr; // value is now 10 (the value of var) // 4. Modifying Value via Pointer *ptr = 20; // var is now 20 // Example Output printf("Value of var: %d\n", var); // Output: 20 printf("Address of var: %p\n", (void*)&var); // Output: Address of var printf("Value via pointer: %d\n", *ptr); // Output: 20 return 0; }