Knowledge Walls
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
Introduction [cont'd]
Input Output Functions [cont'd]
Structures and Unions [cont'd]
# Preprocessor [cont'd]
Operators in pointers in Pointers of Programming in C
2043 Views
Operators in pointers 
Pointer operators are used to increase the address or decrease the address position.

Example
int *ptr;

If ptr variable points address 2002 then performs
ptr++;
ptr variable address moves to 2004 [increase by two bytes of memory because ptr is int datatype]
Program
	#include
	void main(){
	   //+1 increase the address position by 2 bytes for int variable
	   //-1 decrease the address position by 2 bytes for int variable
	   int *ptr;
	   int i;
	   for (i=0;i<5;i++){
	       printf("Enter the number\n");
	       scanf("%d",ptr++);
	   }
	    for (i=0;i<5;i++){
	       printf("%d\n",*(--ptr));
	   }
	}
Output 
Enter the number
12
Enter the number
13
Enter the number
14
Enter the number
15
Enter the number
16

16
15
14
13
12
Previous Topics
Previous lessons of current book.
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Best Lessons of "Programming in C"
Top lessons which are viewed more times.
Structures and Unions of Programming in C
Input Output Functions of Programming in C
Structures and Unions of Programming in C
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details