answersLogoWhite

0

How can one create a pointer to structure in C?

Updated: 8/20/2019
User Avatar

Wiki User

7y ago

Best Answer

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;

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can one create a pointer to structure in C?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

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

Not in C, no.


What is pointer to a member in objective c?

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


How is a structure type pointer variable declared in c?

struct thisorthat *ptr;


How do you create modules in c language?

by using structure in c.........


How will you implement a function pointer inside a structure in c?

Nothing special: struct foo { void *ptr; };


Can you create pointer to a reference in c?

The C language does not support references, that is, the C++ concept of creating an alias to a variable. You can create pointers and dereference them, or you can use the preprocessor's #define mechanism to use another name for a variable. Even in C++, however, you cannot create a pointer to a reference. If you try to, you will end up creating a pointer to the original value. This is because all a reference is is an automatically dereferenced pointer - a compiler shortcut, rather than a totally new feature. So the limitation of not being able to point at a reference isn't really too bad.


What a structure must include if it is a self -referential structure in C programming?

Pointer, eg: struct Person { struct Person *father, *mother, *spouse; int age; char *name; };


What is a structure pointer?

A pointer is a variable that holds address information. For example, in C++, say you have a Car class and another class that can access Car. Then, declaring Car *car1 =new Car() creates a pointer to a Car object.. The variable "car1" holds an address location.


Are structures and pointers related in c plus plus?

Not really, but you can have: - a pointer pointing to a structure (FILE * is an example) - a pointer pointing to a structure-member (eg: struct tm tm; int *ip= &tm.tm_year) - a structure-member that is a pointer (any type) Example: typedef struct TreeNode { struct TreeNode *left, *right; int data; } TreeNode; TreeNode *root = (TreeNode *)calloc (sizeof (TreeNode), 1);


Can you control ports through c plus plus?

Yes. If the ports are memory mapped, then you simply need a pointer to that address, and you need to declare the pointer as volatile. If they are I/O mapped, then you need to create an _asm{} block.


How can you offset a pointer in C?

Increment or decrement the pointer by the required offset.


Pointer arithemetic in C?

no