Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

dynamic memory

What is a pointer in C?

Educative Answers Team

In C, a pointer holds the address of an object stored in memory. The pointer then simply “points” to the object. The type of the object must correspond with the type of the pointer.

type *name;    // points to a value of the specified type

type refers to the data type of the object our pointer points to, and name is just the label of the pointer. The * character specifies that this variable is in fact, a pointer. Here is an example:

int *p;   // integer pointer
string *q;   // string pointer