A pointer is a data type whose value refers directly to (or "points to") another value stored elsewhere in the computer memory using its address.

learn more… | top users | synonyms

53
votes
3answers
22k views

How is a Java reference different from a C pointer?

C has pointers and Java has what is called references. They have some things in common in the sense that they all point to something. I know that pointers in C store the addresses they point to. Do ...
-3
votes
4answers
292 views

What are good strategies in C for dealing with pointer errors of this type?

In C, I often come across errors with code like this prio_queue->head[index] = newEntry; Yields a " "Cannot assign Entry** to Entry* " How do you prevent/debug errors of this type, in general? ...
5
votes
4answers
3k views

What is the difference between a pointer pointing to 0x0 location and a pointer set to NULL?

Is a pointer pointing to 0x0000 the same as a pointer set to NULL? If NULL value is defined in the C language, then what location does it physically translate to? Is it the same as 0x0000. Where can I ...
12
votes
5answers
1k views

How is precedence determined in C pointers?

I've come across two pointer declarations that I'm having trouble understanding. My understanding of precedence rules goes something like this: Operator Precedence ...
4
votes
6answers
1k views

Is it best to minimize using pointers in C?

I think most people would agree that pointers are a major source of bugs in C programs (if not the greatest source of bugs). Other languages drop pointers entirely for this reason. When working in C, ...
3
votes
5answers
1k views

What is the purpose of arrays in C, when pointers could have done the job?

Arrays and pointers are not the same thing in C, although they are related and can be used similarly. So far we all agree. However, I don't see why arrays were included in C, when pointers could have ...
10
votes
5answers
1k views

Who invented pointers?

Pretty simple question, but something I haven't been able to find out. Who was the first person to describe the idea of a pointer? The abstract concept itself?
53
votes
17answers
5k views

What programming problems are best solved by using pointers?

Well, I basically understand how to use pointers, but not how best to use them in order to do better programming. What are good projects or problems to resolve involving the use of pointers so I can ...
4
votes
4answers
2k views

Do I need to understand pointers to use C++?

Well, I love C++, I have been using it for a while: I like all the libraries (Allegro, SDL, QT, Ogre, etc.), but I have a problem: I don't understand pointers. Do I really need them ? I just program ...
3
votes
5answers
1k views

function pointers are so complex to me

I found this code sample in this answer by Armen Tsirunyan. class MyClass { public: typedef void (*funcPtr)(int, int); MyClass(funcPtr whatToCall) { callme = whatToCall; } ...
14
votes
15answers
4k views

Will real world applications ever need a 128-bit flat address space?

This is a bit "one megabyte should be enough for anyone", but... A 64-bit flat address space allows up to 4.3ish billion times more space than a 32-bit address space. That's 17,179,869,184 GiB. ...
2
votes
2answers
239 views

Is a small demo a good idea for an interview?

Unfortunately most of my work is internal -- I was toying with the idea of a small web demo to give the company better insight. What do you think?
16
votes
10answers
6k views

What is so difficult about pointers/recursion? [closed]

In the perils of java schools Joel discusses his experience at Penn and the difficulty of "segmentation faults". He says [segfaults are difficult until you] "take a deep breath and really try ...
4
votes
2answers
862 views

Smart Pointers inside class vs Normal Pointers with Destructor

Regarding pointers which are members of classes. Should they be of a smart pointer type or is it enough to simply deal with them in the destructor of the class they are contained in?
22
votes
10answers
7k views

Why are pointers not recommended when coding with C++

I read from somewhere that when using C++ it is recommended not to use pointers. Why is pointers such a bad idea when you are using C++. For C programmers that are used to using pointers, what is the ...
2
votes
5answers
482 views

Pointer ownership tips

In some libraries I've seen, a lot of emphasis is put into change of ownership of pointers, like for example a class method that allocates and returns a pointer to an object while relinquishing its ...
18
votes
4answers
11k views

Any real use of pointers in C#? [closed]

What is a situation while coding in C# where using pointers is a good or necessary option? I'm talking about unsafe pointers.
61
votes
32answers
9k views

What's a nice explanation for pointers? [closed]

In your own studies (on your own, or for a class) did you have an "ah ha" moment when you finally, really understood pointers? Do you have an explanation you use for beginner programmers that seems ...
8
votes
8answers
8k views

What are use cases and advantages of pointers? [closed]

I often struggle to see the advantages of pointers (except for low level programming). Why use of char* instead of a String or char[] or what advantages pointer arithmetic brings. So what are the ...
11
votes
9answers
553 views

Did anyone else get a deeper understanding about pointers when learning linked lists? [closed]

I'm a student at the University and I'm taking the Data Structures class. When learning linked lists and doubly linked lists, did you guys feel you learned a deeper understanding of pointers, dynamic ...
11
votes
5answers
1k views

If you favor “T *var”, do you ever write “T*”? [duplicate]

Possible Duplicate: int* i; or int *i; or int * i; Thinking about where we place our asterisks; how do those that prefer to keep the "pointerness" away from the type and with the identifier ...
16
votes
12answers
7k views

int* i; or int *i; or int * i; [closed]

What is your favorite method to declare a pointer? int* i; or int *i; or int * i; or int*i; Please explain why. see also: http://www.stroustrup.com/bs_faq2.html#whitespace
8
votes
4answers
331 views

You've shipped, you get a rare seg fault. Pointer checking or let it go?

You've shipped, asserts are turned off, you receive a rare crash report indicating that a null pointer violation occurred in your code. In a development environment, the problem would have been ...