Table of Contents
show
Pointer Increment
Example: Post Increment
#include<stdio.h>
int main()
{
int *ptr = (int *) 2000;
int *fptr;
printf("Initial value of ptr = %u\n",ptr);
fptr = ptr++;
printf("Resultant value of fptr = %u\n",fptr);
printf("Final value of ptr = %u",ptr);
return 0;
}
Output
Initial value of ptr = 2000
Resultant value of fptr = 2000
Final value of ptr = 2002
Example: Pre Increment
#include<stdio.h>
int main()
{
int *ptr = (int *) 2000;
int *fptr;
printf("Initial value of ptr = %u\n",ptr);
fptr = ++ptr;
printf("Resultant value of fptr = %u\n",fptr);
printf("Final value of ptr = %u",ptr);
return 0;
}
Output
Initial value of ptr = 2000
Resultant value of fptr = 2002
Final value of ptr = 2002
Views: 0