• Software and Applications (non-game)
  • Computer Programming
  • C Programming
  • The Difference Between

Can a Structure contain a Pointer to itself?

User Avatar

Wiki User

βˆ™ 2006-08-08 16:37:08

Best Answer

yes, a structure contain a pointer to itself... struct name { int. .... struct name * ptr; }; thats y its called self referential's strutures....

2006-08-08 16:37:08
This answer is:
User Avatar

Your Answer


Related Questions

Can structure contain a pointer itself?

Yes a simple exp is the link list. struct node { int data; struct node *link; }

What is the structure pointer?

Pointer which stores address of structure is called pointer to structure. Explanation : 1)sptr is pointer to structure address. 2) -> and (*) both represents the same.

What is the difference between a structure pointer and a pointer to structure?

Nothing, they are synonyms.

Is pointer is a primitive data structure?

A pointer is not a structure (primitive or otherwise).

What is the difference between structure and pointer?

difference between pointer or structure

What is pointer to a member in objective c?

It is a pointer that points to a member of a structure.

What happens if we use an integer pointer as a member of structure instead of structure pointer?

By declaring an integer pointer you are declaring that any non-zero reference stored in the pointer is guaranteed to be an integer reference. In order to guarantee the reference is actually a structure, the pointer must be declared as such, because casting an integer to a structure can never be regarded as being type-safe.

Can pointer point itself?


How can one create a pointer to structure in C?

Create a pointer of the type (pointer to struct) and assign the address of an instance of the structure to your pointer: typedef struct x { /* ... */ }; struct x my_structure; struct x* ptr = &my_structure;

Why you use double pointer instead of pointer?

Double pointers are better known as pointer-to-pointer types. You use pointers to store the memory address of an object but when the object is itself a pointer, you need to use a pointer-to-pointer in instead. Pointer-to-pointer types are typically used when passing pointers into functions. Pointers allow you to pass objects to functions by reference but the pointer itself is passed by value. If you want to pass the pointer by reference, you need to pass a pointer-to-pointer.

What is the difference between pointers and structure?

A pointer is a variable. A structure is a type.

How do you access a pointer using structure and write a program using that?

> How do you access a pointer using structure Not possible. > and write a program using that Do write.

How many pointers can be used in a c program?

Answergenerally we use simple pointer, void pointer,null pointer, structure pointer. Answerzero or more (unlimited).

What is pointer why you use pointer?

Pointer is a variable that stores the address of another variable. Since pointer is also akind of variable, thus pointer itself will be stored at a different memory location.

Meaning c plus plus pointer to an array and pointer to a structure?

They both mean the same thing; an array is a type of data structure (a linear structure). A pointer variable is just a variable like any other, but one that is used to specifically store a memory address. That memory address may contain a primitive data type, an array or other data structure, an object or a function. The type of the pointer determines how the data being pointed at is to be treated. Pointers must always be initialised before they are accessed, and those that are not specifically pointing at any reference should always be zeroed or nullified with the NULL value. This ensures that any non-NULL pointer is pointing at something valid. Remember that pointer variables are no different to any other variable insofar as they occupy memory of their own, and can therefore point to other pointer variables.

Why pointer is not an object?

A pointer in itself is not an object, because it is not an instance of a class. Of course you can define a class which has only one member, which is a pointer. class Pointer { public void *ptr; }; Pointer p, q, r;

What is a pointer to pointers?

A pointer is a variable like any other. As such, it has memory allocated to it. It is similar to an int in that they both store a value in their memory location. However, whereas an int value is interpreted as a whole number, a pointer's value is interpreted as a memory address. The pointer is said to "point to" the memory address it contains. The type of the pointer determines the type of the variable stored at that memory address. the following is a declaration of a pointer to an integer initialised with the value zero: int * p = new int(0); A pointer to a pointer is no different to an ordinary pointer, except the memory address it points to is that of another pointer. The following is an example of a pointer that points to the pointer we've just declared. int ** pp = p; Pointer-to-pointer variables are typically used whenever you need to pass a pointer by reference. All pointers are passed by value, so the memory address they contain is passed, not the pointer variable itself. To pass the pointer itself, you must pass a pointer to the pointer, which passes the memory address of the pointer. This then makes it possible to change the memory address stored in that pointer. Pointer-to-pointer variables are also used when declaring dynamic, multi-dimensional arrays. For instance, a 2-dimensional array requires a pointer-to-pointer to reference the array itself. This pointer points to a 1-dimensional array of pointers, each of which points to a 1-dimensional array of the actual variables in the array. Unlike a static multi-dimensional array, where the entire array occupies contiguous memory, a dynamic multi-dimensional array may not reside in contiguous memory. Pointer-to-pointer can be extended further to accommodate 3-dimensional arrays, and above. A 3D array requires a pointer-to-pointer-to-pointer, which points to a 1-dimensional array of pointer-to-pointer, each of which references a 2D array, as previously outlined.

32 can you create a linked list with out structure pointer?

Not in C, no.

How can you use pointer is data structure?

Your question makes no sense.

Does ibuprofen contain ibuprofen?

No. A medicine does not contain itself within itself.

What is the difference between structure and pointers?

A structure is a collection of primitives or other structures. A pointer is a memory address. Comparison of the two is like comparing bowling balls to cinder blocks. You can say that a structure defines the layout of the data, while a pointer points to data that is a particular structure.

What is the difference between a function pointer and a pointer to a function?

A pointer to a function is the memory address that stores the address of a function, while the pointer itself is a function pointer.A pointer to a function might be defined as "int (*pf)(int, int);", while to actually point to the function, you would use a function pointer, such as "pf = &func;".

In the 8051 what value does the stack pointer contain immediately after reset?


How structure passing and returning is implemented by compiler?

it uses pointer to stucture.

How is a structure type pointer variable declared?

struct thisorthat *ptr;