Tuesday, May 30, 2023

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

No comments:

Post a Comment