Linked Questions

49 votes
5 answers
177k views

Possible Duplicate: Do you use NULL or 0 (zero) for pointers in C++? Is it a good idea to use NULL in C++ or just the value 0? Is there a special circumstance using NULL in C code calling from C++...
Jookia's user avatar
  • 6,930
16 votes
4 answers
5k views

I am currently in the process of reading a book on C++, and in this book the author explains that it is better to use a constant rather than NULL macro, but without really explaining why or giving any ...
simon's user avatar
  • 1,234
1 vote
4 answers
959 views

Duplicate Do you use NULL or 0 for pointers in C++? When dealing with NULL pointers one can do this if(ptr != NULL){ ... } or this if(ptr != 0){ ... } Are there reasons to prefer one over the ...
Frank's user avatar
  • 66.6k
3 votes
0 answers
2k views

I am currently learning C++ and have gotten to pointers. I am struggling to understand the difference between initializing a pointer to zero and initializing it to nullptr, as demonstrated below. int ...
Dez M's user avatar
  • 77
0 votes
0 answers
22 views

in display function: both 0 and NULL giving the same answer when using in 'while loop' why? when printing temp it shows 0 after completion of while loop that's why I use 0 as termination condition but ...
Garvit Chauhan's user avatar
692 votes
15 answers
431k views

We now have C++11 with many new features. An interesting and confusing one (at least for me) is the new nullptr. Well, no need anymore for the nasty macro NULL. int* x = nullptr; myclass* obj = ...
Khaled Alshaya's user avatar
396 votes
11 answers
441k views

In C, there appear to be differences between various values of zero -- NULL, NUL and 0. I know that the ASCII character '0' evaluates to 48 or 0x30. The NULL pointer is usually defined as: #define ...
gnavi's user avatar
  • 26.3k
56 votes
10 answers
381k views

How can I check if my array has an element I'm looking for? In Java, I would do something like this: Foo someObject = new Foo(someParameter); Foo foo; //search through Foo[] arr for(int i = 0; i <...
Omar Darwish's user avatar
  • 1,665
79 votes
6 answers
52k views

I was interviewing a guy for a mid-level software engineering position yesterday, and he mentioned that in C, NULL is not always zero and that he had seen implementations of C where NULL is not zero. ...
chi42's user avatar
  • 975
27 votes
3 answers
7k views

When used as a boolean expression or transformed into a boolean either explicitly or implicitly, is nullptr consistently false? Is this implementation defined or specified in the standard? I wrote ...
David Thompson's user avatar
5 votes
5 answers
17k views

Why is there a NULL in the C language? Is there a context in which just plain literal 0 would not work exactly the same?
graywolf's user avatar
  • 7,790
1 vote
3 answers
4k views

I don't quite understand why Python will automatically convert any 0 returned to me by a function into a None object. I've programmed in almost all of the common languages, yet I've never come across ...
Brandon's user avatar
  • 920
0 votes
8 answers
354 views

The following crashes with a seg-V: // my code int* ipt; int bool set = false; void Set(int* i) { ASSERT(i); ipt = i; set = true; } int Get() { return set ? *ipt : 0; } // code that I don't ...
BCS's user avatar
  • 79.2k
0 votes
4 answers
2k views

The question itself begs an obvious answer. In any case, here's a snippet of my code... switch(cSet)... case 8:{ //Special Characters finalSet = special; char* charSet = new ...
Mlagma's user avatar
  • 1,260
2 votes
5 answers
1k views

I want to ask what does the (0) mean after the pointer i.e. Node* ptr1(0). struct Node { string info; Node * next }; int main() { Node* ptr1 (0), *ptr2 (0), ptr1 = new Node; ptr2 = ...
Arvin Wong's user avatar

15 30 50 per page