Pointers are voodoo magic

Pointers are voodoo magic

Change my mind

Attached: 1B6DC2C2D8C049E29E89D679202C7B1A.jpg (713x1024, 62K)

Other urls found in this thread:

youtube.com/watch?v=bLHL75H_VEM
twitter.com/AnonBabble

imagine being so fucking dumb you dont understand pointers. anyway, pointers are a meme. just use rust

int *ptr, rtp;
int a;
*ptr = 11;
a = ptr;

>segmentation fault; core dumped

Attached: crow.jpg (324x451, 14K)

Nevermind I changed my mind

This af
How the fuck did so many niggas in data structures not understand pointers? This shit isn’t hard at all

Here you go OP

Attached: 1499476457227.png (694x262, 51K)

this
int *ptr;
*ptr = 11;

is the most obvious null pointer in existence

>Hurr durr I didn't actually learn computer science in my computer science degree
>hey guys let's use node
>check out this sweet CoC
>anime 'girls' hnnnng

what kind of poorfag doesn't just drive his home to their preferred dragon dildo outlet to pick up the goods directly? awful analogy

youtube.com/watch?v=bLHL75H_VEM

you didn't initialize the pointer you retard

I was showing an example.
>implying Rust would let me do this

Attached: bleach.png (639x480, 249K)

pointers are easy but C programmers abuse them in stupid ways for muh 1% optimization.

isn't mutables + the burrow system basically pointers

>needing a retard helmet to stop you from hurting yourself
how about you just don't be retarded

If you understand how memory works, then pointers get easy, but other things get harder.

>driving a motorcycle without protection
top retard

user when in any language you do:

Object gay1 = new Object;
Object gay2 = gay1;

You think the program duplicates gay1 entirely in memory? That would be stupid right? Thats pointers

why is my BIOS corrupted?

Attached: .jpg (540x540, 54K)

Sorry, pajeet here. Why doesn't it duplicate it? What if I want to do different things to gay1 and gay2?

It's known as reference semantics. Your data types are actually just references to objects, not objects themselves. Almost all high level languages do this - C, C++ and Rust are exceptions because they use value semantics (where data is copied on assignment).

You want to clone your object if you do that. Defensive copying is common in languages like Java if they have mutability.

Object gay1 = new Object;
Object gay2 = gay1.clone();

wow that was hard

yes but rust does pretty much all of the dereferencing etc. implicitly for you so 99% of the time you dont have to worry about it. the only thing you need to understand about pointers in rust is

&x points to a location in memory where that is and doesnt copy the whole value onto the stack if your passing it into something

Its a big dilemma and it has plagued programming languages for years. Imagine this:

struct a {
int val;
};

struct b {
a* mem;
};


If you copy a b, it will still point to the same a. So you can't just copy a b, you have to write special code to also copy the a. But then you have to write special code to copy the a.... and it goes all the way down. See the issue?

Cheers, good folk. I'm starting C as my first language.

.clone()
wew lad. the absolute state. the best way is to do

struct obj {
state: u32,
data: u32
}

let mut gay1 = obj { state: 1, data: 1 };
ler gay2 = &gay1;


then if you want to edit to gay1 just change the state to 2.

Don't fool yourself.
99% of the time you will be using pointers only to pass up a big dataset in a function call.

That's what const refs are for, dummy.

In super low level and embedded programming, magic addresses to access hardware aren't unusual. Do this anywhere else and your team lead will fukken shoot you.

Attached: audrey-2-1024x686.jpg (1024x686, 186K)

In those cases you write an "hardware library" and keep your dick there.

When you iterate over a list with an I variable, you store the adresse of the data in a variable right ? 0 is the index of the first element of the list.

Pointers work the same way, they store the adresse of a variable.

That's the best analogy I have.

Too much java does fry your brain

Exactly, your write your lower level code to the hardware, and wrap it up in the OS APIs if you want to make it a full driver. Still, this is a perfectly valid use of the language.

Tfw no dual-cursor OS anywhere in existence
Tfw no "player 2" keyboard
Why are all programmers such hacks bros?

Even if you're not actually making an OS thing, like a GBA rom or something.
You make your pointers to the hardware registers something readable.

A trade degree is not, go do that instead.

This. libgba and libnds use macros like
#define REG_SOUNDCNT_L (*((u16 volatile *) (REG_BASE + 0x080)))
So you don't have to fuck about with the pointers yourself and can just poke the registers.

Reason why Python doesn't need them

>just use rust

Attached: 1522186733817.png (232x266, 4K)

What the fuck? y'all rarded

b foo, bar;
memcpy (foo.mem, bar.mem, sizeof (a));


or if you don't believe in standard functions and your struct really is this stupid

b foo, bar;
foo.mem->val = bar.mem->val;

In my country unless you got contacts or 20 years of experience or willing to do a job that requires you to be willing to destroy your body, it is impossible to get a job.
t. searched job for 3 years in any trade and got nothing, finally got code monkey job that pays more 2nd time I applied

If you're not kidding then that is some hell hole you live in, glad you got a job, though you don't sound you like it all that much.

It is a hard place if you don't have many friends, really went through some rough times for not being able to get a job, only good thing is free health care and free education (both technical and uni).
And yes, I never liked webdev much, but been over 2 years there and I'm changing my life slowly, currently in a selection process to get a sysadmin job, did well on the technical assignment and got a second interview scheduled for Thursday, I'm crossing my fingers.

You're on the right track user, here is hoping for the best.

thanks user

>just use rust

Attached: 1463121053024.jpg (125x125, 2K)

rust has pointers

>int *ptr, rtp;
rtp is also a pointer
never gonna write it like that anymore

>int* ptr, rtp;
new best friend

Attached: 1526960406942.jpg (818x1000, 133K)

>he doesn't understand what a pointer is

Attached: CPgytitWsAA8gNd.jpg (568x443, 32K)

you are incorrect my friend
rpt is not a pointer. It is an Int type
int *ptr, *rpt;

Holy shit. I learned what pointers were when I was probably 9 years old. It was never confusing or complicated, and I started programming with scripting languages...

It's a fucking pointer. It points to memory. What is hard to understand. Even pointer arithmetic isn't fucking hard. If you were asking a more theoretical question like "why should I avoid using pointers," or "why is pointer arithmetic dangerous?" Then I'd understand.

Attached: 1542000321686.jpg (1024x1024, 158K)

What points to pointers? And what points to those pointers? And those pointers?

Attached: DF50B81B0D2847A0907FFF9F54F00F4A.png (655x527, 360K)

pointers

>int *ptr, rtp;
>int a;
>*ptr = 11;
>a = ptr;
>
>>segmentation fault; core dumped
C doesn't hold your hand. At least the problem here is more clear than the type of bullshit that happens in JavaScript (why do I keep getting NaN?)

anchor tags give me nightmares bro

Is there an end to this rabbit trail?

where do they lead to?
who were they for?
how'd they get put there?

double op = "FAGGET"

Attached: 5125.gif (452x308, 3.68M)

No, it's only pointers.

> (You)
>What points to pointers? And what points to those pointers? And those pointers?
A pointer is just a number stored in memory that points to other memory(or even itself) the word "pointer" is a language term. In a sense it's pointers all the way down, but if you look at the compiled ASM you'd understand that a pointer is a language construct, it's an abstraction to make things simpler. It's not complicated though.

> (You)
> anchor tags give me nightmares bro
Haha, at least a tags are more confusing than pointers. Especially in the age of javascript

wew, that was a short friendship

>tiktok garbage
Yeah, they sure are, for braindead zoomers like (You)

If you do not understand pointers, you cannot really learn rust.

It's just the way IEEE 754 floats work.
You will run into the same shit in C or any other language if you use floats.

Attached: 1506898047651.jpg (635x676, 70K)

wouldnt this fail on compulation because you're trying to assign int* to int

> (You)
>It's just the way IEEE 754 floats work.
>You will run into the same shit in C or any other language if you use floats.
Not really. Has more to do with loose typing and overloaded operators and methods

Floats have their own issues in JS too though, some related. I had an irritating issue I fixed on a website once where they decided it was a good idea to calculate tax using a different function in JavaScript in the client than in php on the server. It only showed up on huge orders where all the calculations being 10ths of a cent off started to add up.

They're hit or miss

Guess they never miss huh

Just make a function that takes a house and returns an identical copy but with a dragon dildo already in your room.

Inb4, I know it's less efficient than just giving the address but this way it's cleaner, testable and not a reference hell.

...

>Pointers are voodoo magic
learn assembly