As written, NULL
isn’t defined in your program. Usually, that’s defined in a standard header file — specifically <cstddef>
or <stddef.h>
. Since you’re restricted to iostream
, if yours doesn’t get NULL
implicitly from that header, you can use 0
or, in C++11, nullptr
, which is a keyword and doesn’t require a header. (It is not recommended to define NULL
yourself. It might work sometimes, but it is technically illegal.)
Related Posts:
- C++ – Assigning null to a std::string
- What are the differences between a pointer variable and a reference variable in C++?
- Return array in a function
- What does “dereferencing” a pointer mean?
- Regular cast vs. static_cast vs. dynamic_cast
- What is a smart pointer and when should I use one?
- What does “dereferencing” a pointer mean?
- What is a char*?
- Using NULL in C++?
- What exactly is nullptr?
- How to fix a “invalid operands to binary expression” error?
- What is a dangling pointer?
- What does `*&` in a function declaration mean?
- (->) arrow operator and (.) dot operator , class pointer
- What is uintptr_t data type
- What is the difference between const int*, const int * const, and int const *?
- C++ – No matching member function for call to ‘push_back’
- What is uintptr_t data type
- What does int & mean
- What is the difference between const int*, const int * const, and int const *?
- Pointer to incomplete class type is not allowed
- Passing a 2D array to a C++ function
- basic_string::_M_construct null not valid after constructing subvector of strings
- Can’t resolve Error: indirection requires pointer operand (‘int’ invalid)
- How to create a dynamically-allocated array of const objects, but have values assigned to them?
- How to access the contents of a vector from a pointer to the vector in C++?
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?
- What does int & mean
- C++: Expression must have a constant value when declaring array inside function
- Sorting Linked List C++ with pointers
- Delete 2D array C++
- Is the sizeof(some pointer) always equal to four?
- C++ Expression must have pointer-to-object type
- C++ strings and pointers
- initial value of reference to non-const must be an lvalue
- Typedef function pointer?
- How to initialize a vector of pointers
- What is the use of intptr_t?
- Check if C++ Array is Null
- error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
- Using C-string gives Warning: “Address of stack memory associated with local variable returned”
- Reference to non-static member function must be called
- Why use pointers?
- What’s the difference between * and & in C?
- C++ pass an array by reference
- Function stoi not declared
- C++ Array of pointers: delete or delete []?
- Why should I use a pointer rather than the object itself?
- Function stoi not declared
- C++ correct way to return pointer to array from function
- Warning: comparison of distinct pointer types
- Is null reference possible?
- Initializing pointers in C++
- Difference between function arguments declared with & and * in C++
- Is C++ Array passed by reference or by pointer?
- Difference between the int * i and int** i
- What is a `char*`?
- clearing a vector of pointers [duplicate]
- C++ Swapping Pointers
- Array of Linked Lists C++
- Is it still safe to delete nullptr in c++0x?
- Differences between unique_ptr and shared_ptr
- Sleep for milliseconds
- C++ Cout & Cin & System “Ambiguous” [closed]
- undefined reference to `WinMain@16′
- How can I clear console
- How to go from fopen to fopen_s
- invalid new-expression of abstract class type error
- How can I create objects while adding them into a vector?
- what does “error : a nonstatic member reference must be relative to a specific object” mean?
- “Symbol(s) not found for architecture x86_64” on QtCreator project
- What does the assignment of ~0u to a variable mean in C++?
- expected expression in C++?
- printf with std::string?
- What’s the most efficient way to erase duplicates and sort a vector?
- How can I iterate through a string and also know the index (current position)?
- c++ parse int from string [duplicate]
- C++ array assign error: invalid array assignment
- Is there a median function in the C++ library?
- What is object slicing?
- Java equivalent of cin (C++)
- g++ “because the following virtual functions are pure” with abstract base class
- why can’t I dereference an iterator?
- expected identifier before string constant
- C++ error: expected identifier before “(” token
- Function for C++ struct
- C++ error: double free or corruption (fasttop)
- no match for ‘operator<<’ in ‘std::operator
- error: switch quantity not an integer
- How to create a vector of class objects in C++?
- Is clrscr(); a function in C++?
- Cross compiler prefix and path in eclipse
- How to write log base(2) in c/c++
- Reading a string from file c++
- Expected unqualified-id before ‘[‘ token
- C++ Error: Invalid conversion from ‘char’ to ‘const char*’
- Evaluate a string with a switch in C++ [duplicate]
- C++ JSON Serialization
- stack around the variable…was corrupted
- Creating a list to hold objects in C++