About 6,690 results
Open links in new tab
  1. What does it mean to do a "null check" in C or C++?

    In C and C++, pointers are inherently unsafe, that is, when you dereference a pointer, it is your own responsibility to make sure it points somewhere valid; this is part of what "manual memory …

  2. Is it better to return NULL or empty values from functions/methods ...

    I am looking for a recommendation here. I am struggling with whether it is better to return NULL or an empty value from a method when the return value is not present or cannot be determined. Ta...

  3. c - Are there reasons to assign NULL instead of 0 to non-pointer ...

    Feb 24, 2016 · A common practice is to assign variables with 0 and pointers with NULL. int p = NULL; // instead of int p = 0; int *ptr = NULL; int &ref=p; Are there reasons to assign NULL instead of 0 to a …

  4. Where are null values stored, or are they stored at all?

    A null pointer value is not guaranteed to have all bits zero. 0 is a null pointer constant, but this doesn't mean that myptr == 0 checks if all the bits of myptr are zero.

  5. c++ - What is a 'Null Terminated String' ? - Software Engineering Stack ...

    Jan 4, 2013 · A null-terminated string is a sequence of characters with a trailing 0-valued character. So a string like "Hi" is represented as the sequence {72, 105, 0} (ASCII).

  6. When should pointers be checked for NULL in C?

    The argv vector of strings passed into main is required to be null-terminated by a pointer, similarly to how a string is terminated by a null character: argv[argc] is a null pointer, and you can rely on this …

  7. c++ - Is it reasonable to null guard every single dereferenced pointer ...

    Mandating NULL guards for every single dereferenced pointer is overkill, but You can side-step the whole debate by using a reference instead (if possible) or a const pointer, and assert statements are …

  8. null - Is it possible to make nonnull become part of C++ type system ...

    7 NULL is the billion-dollar mistake but there is nothing in the type system of C++ to prevent it. However, C++ already has const-correctness so implementing NULL -correctness seems trivial: introduce a …

  9. Should one check for null if he does not expect null?

    Both in C++ and Java, checking if optional arguments are null is part of the program's logic. In C++, I would always check mandatory arguments to ensure that a proper exception is thrown so that the …

  10. c++ - Should I cast comparisons to NULL or nullptr? - Software ...

    Dec 12, 2017 · Edit based on proposed answer: Questions are: If I'm stuck with C++03 now but still want to plan for C++11 in the future, is the best option to stick with legacy NULL being set to an integer …