answersLogoWhite

0

Answer

Programming languages store data in different data types. A zero value would belong to a numeric data type such as float, single, double, integer, long, etc. A null string is a variable that references a string (sequence of characters) that is not yet pointing to anything.

Answer

A null string can also be a string of zero length.


Answer
Several programming languages including C and C++ and several assembly languages store strings in "ASCIZ" format, also called "C string" format.
In those languages, a string variable contains only a pointer to the first character in the string, and the end-of-string is marked with the ASCII NUL character.
A programmer using strings in "ASCIZ" format must be aware of the two different ways that a string variable may store no characters:

One way a ASCIZ variable may store no characters:
A string variable may contain the null pointer constant, which is represented by the constant integer 0. All such "null pointers" point to the same location, represented by the constant integer 0, and often called NULL.
No valid string is ever located at that location.
For example,
char * winner_name = 0;
or equivalently
char * winner_name = NULL;
Typically a programmer must write explicit code to check for this possibility first.
For example,
if( winner_name ){ cout << " The winner is: " << winner_name << " !\n"; };

The other way a ASCIZ variable may store no characters:
The string variable may contain the address of a valid memory location that contains no other characters before the end-of-string NUL character.
Some programs have many such locations in memory, located at a variety of addresses (that address is stored in the string variable), that contain such a "null string" or "zero-length string".
For example,
char buffer[BUFFER_SIZE] = "";
or equivalently
char buffer[BUFFER_SIZE] = {'\0'};
.


Sometimes programmers can write the code that handles normal strings in such a way that that code also handles zero-length strings, with no explicit check for a "zero-length string" possibility.
User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
TaigaTaiga
Every great hero faces trials, and you—yes, YOU—are no exception!
Chat with Taiga
CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach

Add your answer:

Earn +20 pts
Q: What is difference between zero value and NULL strings?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the difference between an array shift and unsetting a variable in PHP?

By shifting the values in an array, you are moving a key's value to the previous key. The very first key's value is obliterated. By shifting all values in the array, all keys will have a value of NULL. Unsetting a variable is entirely different -- performing a variable unsetting causes the variable to have a value of NULL, as if it was never set.


What is the difference between null pointer ASCII null character and null string?

A null pointer is a pointer which does not point to any valid memory location, and usually contains the binary value "0" to represent this (this is language dependent). The ASCII null character is a character-sized zero value (in ASCII, it is an unsigned byte with a value of 0), and typically represents the end of a string (esp. as in C and C++). A null string is one that is zero characters of usable string data; in a length-based string, this means the length parameter is set to 0, and in an ASCII null-terminated string, means the first character is set to 0.


Why null values in database?

The 'null'-content of any given field is just that. It's a 'nothing'. Example, if you create a database to hold chemical values for instance. If the values are, for example, real nubers. That would imply that any value that has 0 in it, is just that; zero. It was beeing measured, and found to contain zero. On the other hand if a value was not tested, the value of that compound should be set to 'null'. If a 'null' value isn't supported by the database a workaround is to set 'null' values to -1 (as per the example above). --


What is null character?

A Null Character, is a control character with a value of zero.


What is null signals?

A: Practically all of the bridges used to find the value of passive components uses a null signal to determine the value In reality null means the lack of a signal where it is virtually eliminated when that occurs that is the null or no signal.