DISHA NIRDESHAN

Enlightens your career

Wednesday, June 8, 2011

Questions on Pointers

What is a pointer?

A pointer is a special variable in C language meant just to store address of any other variable or function. Pointer variables unlike ordinary variables cannot be operated with all the arithmetic operations such as '*','%' operators.

Are pointers integers?

No, pointers are not integers.A pointer is an address.It is merely a positive number and not an integer.

 

 

How are pointer variables initialized?

Pointer variable are initialized by one of the following two ways
- Static memory allocation
- Dynamic memory allocation

What does it mean when a pointer is used in an if statement?

Any time a pointer is used as a condition, it means "Is this a non-null pointer?" A pointer can be used in an if, while, for, or do/while statement, or in a conditional expression.

What is 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.

In C, why is the void pointer useful?

When would you use it? The void pointer is useful becuase it is a generic pointer that any pointer can be cast into and back again without loss of information.

 


0 comments :