Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Pointers

Name: Anonymous 2012-03-22 22:56

What's the deal with ''pointers´´?

(&(*((char*)&why)))[0]

Please explain what's the deal with pointers.

Name: Anonymous 2012-03-22 23:22

Pointers add a level of indirection.
"Any problem in computing can be solved by adding another level of indirection." - David Wheeler
So, essentially, pointers can solve any problem in computing.

Name: Anonymous 2012-03-22 23:45

But why do I need ```pointers'''? Superior programming languages like Java don't have them.

Name: Anonymous 2012-03-22 23:47

>>3
Java does have pointers, you just don't generally need to know when it is using them.

Name: Anonymous 2012-03-22 23:50

>>4
Please go on. I would like to know more about this.

Name: Anonymous 2012-03-22 23:57

>>5
They point to your anus

Name: Anonymous 2012-03-23 1:42

Does your computer have memory?
Does that memory have addressing?

If you'd like to put something in that memory, at an address, or read something out of that memory, at an address, then you're going to need a pointer.

Or, you could stick with Java and pretend that your computer doesn't really have memory or addresses and that a magical fairy will always make sure your data goes where it's supposed to go and that the magical garbage fairy will always come along and clean up the stuff that you're done with and thaKILL YOURSELF

Name: Anonymous 2012-03-23 2:25

Pointers are awesome and you do need them. Let me tell you some of the cool shit you can do with pointers:
* Completely dynamic code-base -- use pointers for all your functions and arbitrarily set them at run-time to point to new functions. This allows for a kind of plugin system.
* Accessing other "variables" directly from functions.
* Pointing to shit on the heap. If you want to return certain objects from a function and they are stack based then when the function returns you lose your reference as the stack is gone. So you alloc shit off the heap and return a pointer to it.
* Binary dick trees.

Name: Anonymous 2012-03-23 2:44

>>8
* Segmentation faults.

Name: Anonymous 2012-03-23 2:46

>>8
* Buffer overrun exploits.

Name: Anonymous 2012-03-23 3:04

>>8
* Memory errors that evade testing.

Name: Anonymous 2012-03-23 3:06

>>8
* Inflexible design, due to hard coded freeing rules.

Name: >>10-12 2012-03-23 3:42

* Hand coded optimization when a compiler wouldn't be clever enough to implement it itself (the optimization cannot feasibly be proven correct).

Name: Anonymous 2012-03-23 15:49

Making hardware architecture transparent to the programmer is actually pretty nifty. It's just the way C handles the grammar to use it that's retarded.

Name: Anonymous 2012-03-23 16:02

Interesting, all the points in >>8-13 are valid.  I didn't realize there were actual programmers here.

Pointers are just the most efficient and least safe way of manipulating data.  If you need your hand held, then pointers aren't for you.

Name: Anonymous 2012-03-23 16:58

Thank you very much for your answers.
Actually, I have another question regarding ``pointers´´:

Why does this exist:

a->var

when there's already

(*a).var

?

Name: Anonymous 2012-03-23 17:03

>>16

Why does this exist:


a-b


when there's already


a+ -b


?

Name: Anonymous 2012-03-23 17:16

>>17
Not that you mention it...



That is kinda weird.

Name: Anonymous 2012-03-23 17:17

*Now

Name: Anonymous 2012-03-23 17:17

Pointer not intended.

Name: Anonymous 2012-03-23 18:38

>>22
nice dubs bro

Name: Anonymous 2012-03-23 18:51

>>16
Why does this exist:

arr[5]

when there's already

*(arr + 5)

?

Name: Anonymous 2012-03-23 19:11

Is this

some_struct* a = (some_struct*) malloc(sizeof(some_struct))

and this

some_struct* a = new some_struct

exactly the same the same?

Name: Anonymous 2012-03-23 19:52

And what is the point of using malloc anyway? Do you even at all need it in sepples? I can't think of any scenario where new wouldn't do the job.

Name: Anonymous 2012-03-23 20:02

>>24
malloc(sizeof my_anus)

Name: Anonymous 2012-03-23 20:07

>>24
If you're working with an extern "C" function that calls free() or realloc().

Name: Anonymous 2012-03-23 20:07

long double double main(int artful){
  ask{
    Move $ra,artful
    Jr $ra
  }
}

Name: Anonymous 2012-03-23 20:23

>>25
my_anus = new anus();

Name: Anonymous 2012-03-23 20:51

>>23
No. malloc doesn't call any constructors. malloc returns null and sets errno when it fails, instead of throwing an exception.

Name: Anonymous 2012-03-23 21:04

>>29
returning null is the only exception handler I need

Name: Anonymous 2012-03-23 21:39

My malloc throws java.lang.OutOfMemoryError when it fails.

Name: Anonymous 2012-03-23 21:51

look at me point to these dubs: >>33

Name: Anonymous 2012-03-23 22:18

double check, em;

Name: Anonymous 2012-03-23 22:25

10% of posts contain 100% of the dubs

#occupydubs

Don't change these.
Name: Email:
Entire Thread Thread List