Friday, January 26, 2024

Pointers Part 1: The Basics



So you're eager to learn about pointers but unfortunately you got stuck because they seemed to you terrible in nature? That's not true I know, but many of the people get confused when they arrive at the topic of pointers. Well pointers are the most important tools in C programming and are the one that can make you fly (unless you don't know how to ride over them). In this article we're going to learn basics of pointers.
Pointers are the varaibles that store addresses of other variables. Easy ain't it?
So lets start with the decleration of a pointer, pointer is decreleared as:
data_type *var_name;
e,g
int *pt;
well the astrisk(*) before the variable name is the thing that makes variable a pointer. So far so good now what?
Now lets say we want to store address of a variable in our pointer variable that seems pretty complex..!
Let's do it:
int number = 100;
int *pt = #
Is it really complex..?
what we are doing here is that we are first declaring and initializing a integer variable (number) with value of 100 and then we declare and initialize a pointer variable (pt) with the address of number variable. Now pt (pointer variable) contains the address of number (integer varaible). So what? Now we can use this pointer variable to change the value of number variable. Is this some kind of Magic? Maybe. Lets' do it:
*pt = 200;
what we have done here is that we De-referencing the pt variable with the asterisk (*) and then assigned it the value of 200 now the number variable contains 200. Isn't it a magic? De-referencing is used for accessing the value of the variable towards which our pointer is pointing simple. So lets write a full program of what we have learned so far.
/*Pointer Basics: Creating and Using Pointers*/
#include<stdio.h>
int main(void){
  int number = 100;
  int *pt = &number;
  printf("Value of 'number' is: %d", number);
  printf("Address of 'number' is: %p", pt);
  *pt = 200;
  printf("New value of 'number' is: %d", number);
  return 0;
}
What this whole program did was it created a integer variable and a pointer to integer variable and then printed out the value and address of the 'number' variable and after that we De-referenced the pointer variable so that we can access the value to which our pointer variable is pointing and changed the old 100 value with new 200 value and at last we printed that out. Easy isn't it?
But do you know that you can get the address of a variable even by using ampersand (&) operator? Lemme show you how. I'll declare and initialize a variable 'var' and then print it to screen using ampersand (&) operator:
int var = 10;
printf("Address of 'var' is %p\n", &var);
the last statement here will print out the address of 'var' not value so that means it is equal to this statement:
int *pt = &var;
printf("Address of 'var' is %p\n", pt);
here we first assigned the address of 'var' to pointer variable 'pt' and then printed out the address of 'var' using the pointer variable (pt).
So lets write another program that will wrap up this part of 'Pointer Basics':
/*Pointer Basics Part 1: Program 2*/
#include<stdio.h>
int main(void){
   int var = 10;
   int *pt = &var;
   printf("The Value of 'var' is: %d\n", var);
   printf("De-referencing: *pt = %d\n", *pt);
   printf("Ampersand: The Address of 'var' is %p\n",  &var);
   printf("pt = %p\n", pt);
   return 0;
}
So that's the end of first part watch out for the next part in which we'll tighten our grip on pointers and get ready for some Advanced '*po(inter)-fo'.

Continue reading


  1. Tools Used For Hacking
  2. Hacker Techniques Tools And Incident Handling
  3. Hack Tools Download
  4. Hacking Tools Software
  5. Hacker Tools 2019
  6. Hacking App
  7. New Hacker Tools
  8. Pentest Tools Framework
  9. Bluetooth Hacking Tools Kali
  10. Hacking Tools Usb
  11. Tools For Hacker
  12. Hacking Tools Name
  13. Hacking Tools Windows 10
  14. Pentest Tools Website Vulnerability
  15. How To Make Hacking Tools
  16. Hack App
  17. Hacks And Tools
  18. Hack Tools For Windows
  19. Hacking Tools For Windows
  20. Hacking Tools Windows 10
  21. Hacking Tools Free Download
  22. How To Install Pentest Tools In Ubuntu
  23. Hacking Apps
  24. Hacker Tools 2020
  25. Hacking Tools 2020
  26. Blackhat Hacker Tools
  27. How To Make Hacking Tools
  28. Pentest Tools Tcp Port Scanner
  29. World No 1 Hacker Software
  30. World No 1 Hacker Software
  31. Hacker Tools Software
  32. Tools For Hacker
  33. Hacking Tools
  34. Hacking Tools Github
  35. New Hack Tools
  36. Hacking Apps
  37. Hack Tools
  38. Pentest Tools Tcp Port Scanner
  39. Growth Hacker Tools
  40. Hacking Tools Kit
  41. Hacking Tools And Software
  42. Hack Tools Pc
  43. Hacking Tools Kit
  44. Hacking Tools Usb
  45. Tools 4 Hack
  46. Hacker Search Tools
  47. Best Hacking Tools 2020
  48. Hacker Tools Windows
  49. Nsa Hacker Tools
  50. Hacker Tools For Windows
  51. Easy Hack Tools
  52. Hacker Tools Online
  53. Beginner Hacker Tools
  54. Hacker Tools Github
  55. Physical Pentest Tools
  56. Hacking Tools For Kali Linux
  57. Physical Pentest Tools
  58. Hacker Search Tools
  59. Hacking Tools For Windows Free Download
  60. Hack Tools Online
  61. What Is Hacking Tools
  62. Termux Hacking Tools 2019
  63. Top Pentest Tools
  64. Pentest Tools Windows
  65. Hacking Tools Name
  66. Hacker Tools List
  67. Beginner Hacker Tools
  68. Hacking Tools 2020
  69. Hacking Tools For Pc
  70. What Are Hacking Tools
  71. Hacker Tools Mac
  72. Hacking Tools For Windows Free Download
  73. Pentest Tools List
  74. Hacking Tools For Windows
  75. What Are Hacking Tools
  76. Pentest Tools Linux
  77. Pentest Tools Bluekeep
  78. Hack Tools Online
  79. Hacking Tools
  80. Hacking Tools Name
  81. Pentest Tools Nmap
  82. Hacker Tools Apk Download
  83. Hacking Tools For Mac
  84. Hacker Tools Mac
  85. Hacking Tools Mac
  86. Hacking Tools For Kali Linux
  87. Hacking Tools 2020
  88. Pentest Tools Android
  89. Pentest Tools Android
  90. Tools For Hacker
  91. Pentest Tools Github
  92. Hacker Tools Online
  93. Hack Tools Mac
  94. Hacking Tools Windows
  95. Hacker Search Tools
  96. Kik Hack Tools
  97. Pentest Automation Tools
  98. Hacking Tools For Beginners
  99. Hacking Tools 2019
  100. Tools For Hacker
  101. New Hack Tools
  102. Hacking Tools Hardware
  103. Hack Tools For Games
  104. Hack Tools Download
  105. Hacker Tools List
  106. Pentest Box Tools Download
  107. Hack Apps
  108. Tools 4 Hack
  109. Hacking Tools Windows
  110. Hacker Tools For Pc
  111. Wifi Hacker Tools For Windows
  112. Pentest Tools For Windows
  113. Pentest Tools Linux
  114. Hack Tools Github
  115. Github Hacking Tools
  116. Pentest Tools Website
  117. New Hacker Tools
  118. What Is Hacking Tools
  119. Pentest Tools Website
  120. Hacker Tools Github
  121. New Hacker Tools
  122. Hacking App
  123. Pentest Tools Open Source
  124. Pentest Tools Tcp Port Scanner
  125. Hacker Tools
  126. What Is Hacking Tools
  127. Hacking Tools
  128. Hack And Tools
  129. Hacker Tools For Pc
  130. Pentest Tools Find Subdomains
  131. Hacker Tools For Windows
  132. Hacker Tools 2020
  133. Pentest Tools Url Fuzzer
  134. Hack Tools 2019
  135. Pentest Tools Github
  136. Hacking Tools For Kali Linux
  137. Hacking Tools For Beginners
  138. World No 1 Hacker Software
  139. Hack Tools For Mac
  140. What Is Hacking Tools
  141. Hacker Tools 2019
  142. Pentest Tools For Mac
  143. Hack Tools For Games
  144. Install Pentest Tools Ubuntu
  145. Hacking Tools For Beginners
  146. Hacking Tools Usb
  147. Hack Tools
  148. Pentest Box Tools Download
  149. Hackers Toolbox
  150. Pentest Tools Port Scanner
  151. Pentest Tools Android
  152. Best Pentesting Tools 2018
  153. Hacking Tools Name
  154. Free Pentest Tools For Windows
  155. Pentest Tools Url Fuzzer
  156. Hacking Tools Pc
  157. Hacking Tools 2019
  158. Hacker Tools Free
  159. Hacking Tools And Software
  160. Pentest Box Tools Download
  161. Hacking Tools Name
  162. Hack Tools Online
  163. Hacker Techniques Tools And Incident Handling
  164. Pentest Tools List
  165. Hacking Tools
  166. Pentest Tools Nmap
  167. Hack Tools Pc
  168. Tools For Hacker

No comments:

Post a Comment