C Pointers

  Home  C Language  C Pointers


“C Pointers frequently Asked Questions by expert members with experience in C pointers. These questions and answers will help you strengthen your technical skills, prepare for the new job test and quickly revise the concepts”



31 C Pointers Questions And Answers

21⟩ Tell me is NULL always defined as 0(zero)?

NULL is defined as either 0 or (void*)0. These values are almost identical; either a literal zero or a void pointer is converted automatically to any kind of pointer, as necessary, whenever a pointer is needed (although the compiler can't always tell when a pointer is needed).

 144 views

23⟩ Tell me when is a void pointer used?

A void pointer is used for working with raw memory or for passing a pointer to an unspecified type.

Some C code operates on raw memory. When C was first invented, character pointers (char *) were used for that. Then people started getting confused about when a character pointer was a string, when it was a character array, and when it was raw memory.

 142 views

24⟩ How many levels of pointers have?

The answer depends on what you mean by "levels of pointers." If you mean "How many levels of indirection can you have in a single declaration?" the answer is "At least 12."

 137 views

25⟩ Explain indirection?

If you declare a variable, its name is a direct reference to its value. If you have a pointer to a variable, or any other object in memory, you have an indirect reference to its value. If p is a pointer, the value of p is the address of the object. *p means "apply the indirection operator to p"; its value is the value of the object that p points to. (Some people would read it as "Go indirect on p.")

 147 views

28⟩ Do you know NULL pointer?

A null pointer does not point to any object.

NULL and 0 are interchangeable in pointer contexts.Usage of NULL should be considered a gentle reminder that a pointer is involved.

It is only in pointer contexts that NULL and 0 are equivalent. NULL should not be used when another kind of 0 is required.

 143 views