30
votes
3answers
7k views

How is a Java reference different from a C pointer?

C has pointers and Java have 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 ...
17
votes
10answers
3k 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 ...
16
votes
9answers
3k views

What is so difficult about pointers/recursion?

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 ...
15
votes
12answers
2k 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
12
votes
5answers
615 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 ...
11
votes
5answers
963 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 ...
5
votes
4answers
623 views

What's so bad about pointers in C++?

To continue the discussion in Why are pointers not recommended when coding with C++ Suppose you have a class that encapsulates objects which need some initialisation to be valid - like a network ...
5
votes
4answers
1k 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 ...
4
votes
6answers
875 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, ...
4
votes
6answers
614 views

why are both index[array] and array[index] valid in C?

For example consider: int index = 3; int array[4] = {0, 1, 2, 3}; then both index[array] and array[index] are valid expressions, much like *(index + array) and *(array + index). In C arrays why is ...
2
votes
5answers
711 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 ...
2
votes
3answers
650 views

Functions returning pointers

C++ noob here. I have a very basic question about a construct I found in the C++ book I am reading. // class declaration class CStr { char sData[256]; public: char* get(void); }; // ...
1
vote
8answers
1k views

Pointers in C vs No pointers in PHP

Both languages have the same syntax. Why does C have the weird * character that denotes pointers (which is some kind of memory address of the variable contents?), when PHP doesn't have it and you can ...
-2
votes
1answer
128 views

Object-Oriented Programming With ANSI-C [closed]

I am trying to expand my understanding the history and involvement of OOP. Recently I have been looking into OOP in ANSI-C, which is described in Object-Oriented Programming With ANSI-C by Axel ...
-2
votes
4answers
478 views

C simple arrays and pointers question

So here's the confusion, let's say I declare an array of characters char name[3] = "Sam"; and then I declare another array but this time using pointers char * name = "Sam"; What's the ...

1 2
15 30 50 per page