- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Explain the concept of pointers in C language
The pointer is a variable that stores the address of another variable.
Features of Pointers
Pointer saves the memory space.
The execution time of a pointer is faster because it directly accesses to memory location.
The memory is accessed efficiently with the help of a pointer.
Memory is allocated and deallocated dynamically.
Pointers are used with data structures.
The syntax for the pointer is as follows −
pointer = &variable;
Example
Following is the C program for the pointer −
#include <stdio.h> int main(){ int x=40; //variable declaration int *p; //pointer variable declaration p=&x; //store address of variable x in pointer p printf("address in variable p is:%d
",p); //accessing the address printf("value in variable p is:%d
",*p); //accessing the value return 0; }
Output
When the above program is executed, it produces the following result −
Address in variable p is:5ff678 Value in variable p is:40
Operator * serves two purposes which are as follows −
Declaration of a pointer.
Returns the value of the referenced variable.
Operator & serves only one purpose, which is as follows −
Returns the address of a variable.
- Related Articles
- Demonstrate the concept of pointers using C language
- Write a program to understand the concept of pointers in C language?
- Explain the concept of Sorting in C language
- Explain the concept of stack in C language
- Explain array of pointers in C programming language
- Explain the pointers to unions in C language
- Explain the concept of Arithmetic operators in C language
- Explain the concept of pointer accessing in C language
- Explain the concept of Linked list in C language
- Explain the concepts of Pointers and arrays in C language
- Explain the concept of union of structures in C language
- Explain Arithmetic operations using pointers in C language?
- Explain Near Far Huge pointers in C language
- Explain the concept of Uninitialized array accessing in C language
- Explain the pointers for inter-function communication in C language.

Advertisements