answersLogoWhite

0

What is null macro?

Updated: 11/4/2022
User Avatar

Wiki User

7y ago

Best Answer

The NULL macro is an implementation-defined macro. It is used to symbolise the zero address (0x0) in C programs and older C++ programs. It is not type safe, but is the conventional method of assigning the zero address to a pointer variable. C++11 introduced the type-safe nullptr data type.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is null macro?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the difference between a null pointer and a null macro?

Using a NULL macro to make C portableI'll assume that you're asking your question for C type language programming. A NULL pointer is a pointer that's guarnteed to point to nothing. This may be 0 in a UNIX/Linux system or some other address in another system. Using the NULL macro to set/initialize your pointers will make your programs more portable among systems than using something like the 0.#include char *c = 0; // initialize to NULL--not portablechar *p = NULL; // initialize to NULL as defined in stdio is portableAddendumThe code:char *c = 0;actually is portable because the compiler converts 0's used in a pointer context (cast to a pointer) to the machine's representation of a NULL pointer, which may or may not be all 0 bits. The NULL macro itself might be defined as something like 0 or (void *)0, and both definitions are portable. As a corollary, the following code is also portable:if (!c) {// do something}because it is equivalent to:if (c != 0) {// do something}and the 0 above is converted to a NULL pointer because it is being compared with a pointer.


Null in programming?

in Russian Null means zero. in some languages Null is a macro for zero. in others Null is a single-tone object which referes to the value Null and thus could be compared to other values. Null has many names from nill Nill nil in diffrent languages. most of the time, Null is used to indicate, no value is set to a variable.


If null is compared with null what is the result-true or false or null or unknown?

You mean SQL? NULL = anything IS NULL NULL <> anything IS NULL ... NULL IS NULL = TRUE NULL IS NOT NULL = FALSE


C plus plus program of periodic table?

The Periodic Table Of Elements has a well defined order. The layout can be emulated easily since the arrangement is quite logical.The first step would be to define a struct containing the following members as a minimum:- atomic number (int - number of protons in its nucleus)- symbol (char* - short form of the element name)- name (char* - long form of the element name)i.e.:struct elementinfo {int atomicnumber;char *symbol, *name;};Other members can be added as your program develops.The next step is to arrange the table itself. If you're using Win32 or another graphical system, it's a matter of drawing a box (Win32 would require a MoveToEx() call and four LineTo() calls) and TextOut() (or a related function) for the atomic number and element symbol (centered horizontally and aligned top and bottom respectively).Including conio.h or curses.h would give you the ability to position the cursor and even change the text color, allowing for an alternate "graphical" method.To keep things simple, storing the elements in an array would require something akin to the following:struct elementinfo elementlist[]={{1, "H", "Helium"}, {0, NULL, NULL}, {0, NULL, NULL},{0, NULL, NULL}, {0, NULL, NULL}, {0, NULL, NULL},{0, NULL, NULL}, {0, NULL, NULL}, {0, NULL, NULL},{0, NULL, NULL}, {0, NULL, NULL}, {0, NULL, NULL},{0, NULL, NULL}, {0, NULL, NULL}, {0, NULL, NULL},{0, NULL, NULL}, {0, NULL, NULL}, {2, "He", "Helium"},{-1, NULL, NULL},{3, "Li", "Lithium"}, {4, "Be", "Beryllium"}, {0, NULL, NULL},{0, NULL, NULL}, {0, NULL, NULL}, {0, NULL, NULL},{0, NULL, NULL}, {0, NULL, NULL}, {0, NULL, NULL},{0, NULL, NULL}, {0, NULL, NULL}, {0, NULL, NULL},{5, "B", "Boron"}, {6, "C", "Carbon"}, {7, "N", "Nitrogen"},{8, "O", "Oxygen"}, {9, "F", "Fluorine"}, {10, "Ne", "Neon"},{-1, NULL, NULL},...{-2, NULL, NULL}};In the above array, {0, NULL, NULL} represents a blank displayed for that particular cell, and {-1, NULL, NULL} represents a newline. The {-2, NULL, NULL} signifies the end of the table. The following for() loop would wrap around your display code like so:for (count=0; elementlist[count].atomicnumber!=-2; count++) {if elementlist[count].atomicnumber==-1) {// jump to next line of elements}else {// display current element}}Drawing this graphically, you'd have to keep track of the current cursor (X, Y) position.If you are sending this to stdout or another text stream (i.e. text file), you could draw each line, referencing the array of elements as you go. The list of elements would have to be stored in a nested array: the outermost array contains each line of elements in an array. This would do away with the {-1, NULL, NULL} terminating each line of elements.Extending this code to use classes would be relatively simple, but might only make sense if you were drawing this graphically storing each element as an object.The Lanthanides and Actinides, since they're displayed separately from the main table, would probably have to be stored separately for sake of convenience.Also, as laboratories continue to synthesize (or, on the rare chance, discover) new elements, the layout of the table may change (even drastically) to suit. Thus, the code would have to be altered accordingly.See the related links below for more ideas on how to design a program that displays the Periodic Table of Elements.(Note: Code originally posted was copyrighted. Added to related links.)


What is enclosed between a macro header statement and a macro end statement?

The macro content.

Related questions

What is a NULL Macro?

# define pi 3.17 // tihs is a preprocessing directive macro. "pi" is called macro template " 3.17" is the macro value. means in entire program pi value is 3.17. if we declared like # define pi 0 means pi value is zero means null. so the macro template which carries a null value is called a NULL MACRO.


What is a null macro what is the difference between a null pointer and a null macro?

NULL Macro is simply what is defined as 0 in a macro provided by the libraryNull pointer is a pointer which has 0 or NULL value stored and points to nowhwere still it points to 0x00 i.e. the first memory location of the OSNull pointer != Uninitialized pointer because an uninitialised pointer can point anywhere in the memory location ...but a NULL pointer surely points to no where(but still behind the scene we can say that it only points to 0x00). Never we can retrive a Null pointer location using th"&" operator..neither will malloc/calloc return NULL IF THERE IS SPACE IN THE MEMORY. NULL pointer is unique !!nishantnitb@aol.com


What is the difference between a null pointer and a null macro?

Using a NULL macro to make C portableI'll assume that you're asking your question for C type language programming. A NULL pointer is a pointer that's guarnteed to point to nothing. This may be 0 in a UNIX/Linux system or some other address in another system. Using the NULL macro to set/initialize your pointers will make your programs more portable among systems than using something like the 0.#include char *c = 0; // initialize to NULL--not portablechar *p = NULL; // initialize to NULL as defined in stdio is portableAddendumThe code:char *c = 0;actually is portable because the compiler converts 0's used in a pointer context (cast to a pointer) to the machine's representation of a NULL pointer, which may or may not be all 0 bits. The NULL macro itself might be defined as something like 0 or (void *)0, and both definitions are portable. As a corollary, the following code is also portable:if (!c) {// do something}because it is equivalent to:if (c != 0) {// do something}and the 0 above is converted to a NULL pointer because it is being compared with a pointer.


Null in programming?

in Russian Null means zero. in some languages Null is a macro for zero. in others Null is a single-tone object which referes to the value Null and thus could be compared to other values. Null has many names from nill Nill nil in diffrent languages. most of the time, Null is used to indicate, no value is set to a variable.


Null Null Null?

Very small.


If null is compared with null what is the result-true or false or null or unknown?

You mean SQL? NULL = anything IS NULL NULL <> anything IS NULL ... NULL IS NULL = TRUE NULL IS NOT NULL = FALSE


What is the difference between executing a macro and calling a macro?

Calling a macro loads the macro into memory, while executing the macro runs the macro.


How do you get to the null in supersecret?

There is no null, it is just what it says when you log out. There is a null.


What is macro call?

Nested macro calls refer to the macro calls within the macros. A macros is available within other macro definitions also. In the scenario when a macro call occurs, which contains another macro call, the macro processor generates the nested macro definition as text and places it on the input stack. The definition of the macro is then scanned and the macro processor complies it.


What is nested macro calls?

Nested macro calls refer to the macro calls within the macros. A macros is available within other macro definitions also. In the scenario when a macro call occurs, which contains another macro call, the macro processor generates the nested macro definition as text and places it on the input stack. The definition of the macro is then scanned and the macro processor complies it.


What is is null?

main(){ char str[5]="hello"; if(str==NULL) printf("string null"); else printf("string not null"); }


What is the subset of null set?

The null set. Every set is a subset of itself and so the null set is a subset of the null set.