Computer Programming
Database Programming

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


Top Answer
User Avatar
Wiki User
2013-01-12 05:31:28
2013-01-12 05:31:28

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.

User Avatar

Related Questions

It depends on what type of data you wish to manipulate.

Example: int x; -- integer int *px= &x; -- pointer to integer int **ppx= &px; -- pointer to pointer to integer int ***pppx= &ppx; -- pointer to pointer to pointer to integer

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.

difference between pointer or structure

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

Error message, mainly. The following operations are legal: ptr + integer (pointer) ptr - integer (pointer) ptr - ptr (integer)

It changes to a hand instead of a arrow :) ->

Data type is mandatory in every variable-declaration.Example:int i; -- integerint *pi; -- integer-pointerint ai[10]; -- integer-arrayint *api[10]; -- array of integer-pointersint (*api)[10]; -- pointer to integer-array

A pointer is a variable that holds an address in memory. int * pPointer = new int; This code creates a pointer to an integer, and assigns it an address of an integer object on the heap.

A pointer is a variable which is used to store address of a variable. They are used to point to another *p; // creates a pointer of integer typeint num; // an integer variablep=# //pointer variable p is assigned with address of num

A pointer is initialized by assigning the address of some object to it ... int a; // an integer int *pa; // a pointer pa = &a; // initialize the pointer (*pa); // use the pointer ... by allocating memoryand assigning that address to it ... int *pa; // a pointer to an integer pa = malloc (1 * sizeof(int)); // allocate if (pa == NULL) {... exception processing ...} (*pa); // use the pointer ... or by doing address computation with it ... int a[10]; // an array of integers int *pa; // a pointer to an integer pa = &(a+3); // initialize to the fourth element (*pa); // use the fourth element

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

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;

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.

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

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

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

It is not exactly a data-type, it is rather a data-type-constructor; for example pointer-to-integer is a data-type.

all pointers are 4 bytes in 32 bit system

// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);

Your question makes no sense.

Of course. But why? int *p = (int *)"string";

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

Try this: printf ("In this platform an integer pointer uses %d bytes\n", (int) sizeof (int *));

Copyright ยฉ 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.