NULL pointers can be used when allocating dynamic memory for the data, such as:. The main advantage of using the NULL terminator is that we can check whether a value is null quickly. In theory, any of the other variables could have been used instead of NULL, but usage of such might require an explicit comparison for a specific value. Every time the result of a calculation is zero, a flag is automatically set in the status register, and this can be used in conditional instructions, such as conditional jump.
Hence the use of NULL has added advantage as it represents invalid value pointers. The language specification, especially in the C standard library, treats a NULL character as a special value for a pointer, there will be no difference for the processor core.
The address zero is as good for an address as any other number. Whenever a NULL is not used for signaling an invalid value, it can be used for a valid address. I've tried setting the pointer to null but keep getting a segmentation error.
Originally Posted by Bladactania. Do you actually want to remove the data or just free the memory? These aren't the same things if I recall correctly. Originally Posted by Meldreth. All things begin as source code. Source code begins with an empty file. Originally Posted by Snafuist. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to check if a char is null Ask Question.
Asked 3 years, 7 months ago. Active 8 months ago. Viewed 30k times. Improve this question. Cheeseburger Cheeseburger 55 1 1 gold badge 1 1 silver badge 8 8 bronze badges. Why not use string? Add a comment. Active Oldest Votes.
0コメント