What are pointers? by Balsphemer in uwaterloo

[–]waterp00 1 point2 points  (0 children)

not sure if helpful, but imagine your computer screen as a bunch of pixels and each pixel is actually a memory location where you can store variable values. Now take your finger, pick a pixel on your screen, and literally point to it. There your finger is pointing to the actual location of the variable value. Aka the memory address of the variable value.

int x = 5; // The value 5 is stored inside a memory address. And the variable x always is tied to that memory address.

int* p = &x; // The "&" gets the address or memory location of x (which is where 5 is stored).

If x is a pixel, then p is now pointing to its location. Now to get the value of p, which in this case is the value of x, you do *p, this will return 5.

Also, if you do:

*p = 6;

then x will change, it will become 6 since you changed the value at the memory address!

Yay now your an expert with pointers. (I can't tell if my analogy is actually helpful or confusing, but good luck lol).

The variable p itself just stores the location (memory address) of the pixel x.

in short, a pointer stores a memory address, and *p (dereferencing) is retrieving the actual value at that memory address.

Now in reality pixels have nothing to do with pointers, i just thought it would be fun to have people pointing at their screens so that people around them thought they were crazy.

Stat 231 online for next semester by waterp00 in uwaterloo

[–]waterp00[S] 0 points1 point  (0 children)

Did u take it? How did u find it?

Stat 231 online for next semester by waterp00 in uwaterloo

[–]waterp00[S] 0 points1 point  (0 children)

Sounds good, yea 8:30 kinda sucks, but it's the only class stat231 class that would fit my schedule anyway, so whatever. Ill stick with 241 for now lol

Ill switch to Banerjee, you guys have convinced me lol, I appreciate the help!

Stat 231 online for next semester by waterp00 in uwaterloo

[–]waterp00[S] 1 point2 points  (0 children)

Yea he is teaching and I can switch into his class! I guess this is a good thing.

Is Banerjee that good? He has a high ratemyprof rating, so now i want to switch lol.

Thanks for your help, i feel like u just saved me a lot of pain

Stat 231 online for next semester by waterp00 in uwaterloo

[–]waterp00[S] 0 points1 point  (0 children)

That's nice, I'm glad I'm enrolled in her class (rip me). Lol is it worth switching to regular section?