/*AN IMPLEMENTATION OF WRITIING A TABLE USING POINTER*/
#include<stdio.h>
int main()
{
unsigned char arr[10];//TAKE ARRAY OF CHAR TYPE
int num,i;
num=15;//TABLE OF 15
unsigned char *p;
p=arr;//PUT BASE ADDRESS OF ARRAY INTO THE POINTER
for(i=1;i<=20;i++)//UPTO 20 TABLE WILL BE WRITTEN
{
*(p+i)=num*i;//num*i =15*(1 to 20)=placed in address of pointer..//
//WARNING:--DO NOT WRITE INTO POINTER LIKE (p+i)=&(num*i)...it will change the address of pointer
//*(p+i)=variable will put the value in address of pointer ....so not changing the address of pointer..//
printf("\n%d*%d=%d",num,i,*(p+i));//print the table
}
return 0;
}
//[root@localhost]/home/emblogic/asd# ./a.out
//
//15*1=15
//15*2=30
//15*3=45
//15*4=60
//15*5=75
//15*6=90
/15*7=105
///15*8=120
//15*9=-121
//15*10=0
//15*11=-91
//15*12=-76
//15*13=-61
//15*14=-46
//15*15=-31
//15*16=-16
//15*17=-1
//15*18=14
//15*19=29
//15*20=44#
//will write values like this so...more than 10 value 150 value ...u know char had max. of 255 value in unsigned type ...so bigger value will be overflowed into same buffer...so...try.. int *ptr..it will also not work...;