Secret life of Pointers

Secret life of Pointers

A story of how I broke into sapa

·

3 min read

Table of contents

No heading

No headings in the article.

NB: All characters in italics are not in standard English.

If you didn't understand pointers. Read this story 🙂🙂 Look at pointers like telling your friend where you kept your money in your room. Once he knows where it is..he can do anything, he can swap it, replace it with another thing, or even delete it(replacing it with nothing"0"). By telling him where it is, he's now a pointer. I imagine stuff like this when solving some pointers problems🫠. I'm Nico and my friend's name is Emma My money is kept in my safe but he doesn't know. So I tell him where it is(My first fuck up)😭. Buh I, as the owner, know where it is. So ; safe Nico = 50k; /*type of container is "safe". My safe is labelled with my name.*/ Ofc why not 🙂. Who no go lock that kain money for 2022🫠 #sapa

C syntax example- int n = 50000; /*that's the container storing my money.*/ But on telling my friend where it is. I have to distinguish whether he's only a reference guy or a pointer.

e just manage sabi where I keep am.

So I must declare/name him differently.

May e know e place for street...e no Fi dey drag with me. safe *Emma = &nico;(&nico - specific location of my safe) /*Giving him the address of my safe and declaring him as a pointer.*/ Example C syntax - int *e = &n; Note: Once it's declared as a pointer, the computer now knows it's a pointer and if u wish to assign it to it again. You can simply say; e = &b; If u even just declare int *e; You should assign this way; e = &b; The most important thing is the computer must know that it's a pointer from the start. Once that's known, you can give the address as u like. Now even if he knows where it is, he may not still be able to access it. Let's look at the * sign now as a key. This step is called dereferencing/indirection. He, as the reference/pointer guy is trying to access what I stored at the address he now knows that, if he wants to swap the book with something else He has to say; *emma = paper I no know how e take find key ooo😭😭...be like 9ja safe no safe again o😭😭😭

C- syntax example - *e = p; I go look wetin dy my safe... ``` print("safe = "); //output: sapa go kill u

printf("n = %d", n); // output: n = paper ``` I see paper wey Dem write..sapa go kill u😭

Well, im just thief my money, drop paper inside.

Lesson..friends are evil🥲

Keynote: It's important the pointer knows the type of value it's storing. U no go tell pikin say u keep money na, abi?.he simply won't understand the value and might well🫠.

That's the purpose of declaring the pointer as int. Or Emma as safe.

If I for declare Emma as bottle. Maybe e for no Fit carry the money comot, e for think say na water I keep there.🥲

Â