วันศุกร์ที่ 29 กุมภาพันธ์ พ.ศ. 2551

พอยเตอร์

#include "stdio.h"
#include "conio.h"


void main()
{
int *pt,a,b;
a = 20;
pt = &a;
b = *pt;
clrscr();

printf("%d\n",b);
}






#include "stdio.h"
#include "conio.h"


void main()
{
int *pt,a;
a = 20;
pt = &a;
clrscr();
printf("Address pointer by pointer pt stored value of %d\n",*pt);
*pt = 10;
printf("After indirection assignment\n");
printf("a = %d\n",a);
}






#include "stdio.h"
#include "conio.h"


void main()
{
int *pt;
int a;
pt = &a;
*pt = 15;
clrscr();
printf("%d\n",a);
}






#include "stdio.h"
#include "conio.h"


void main()
{
int *ipt;
*ipt = 15;
clrscr();
printf("%d\n",*ipt);
}






#include "stdio.h"
#include "conio.h"


void main()
{
int number[3];
int *pt;

clrscr();
number[0] = 100;
number[1] = 200;
number[2] = 300;
pt = number;
clrscr();

printf("number[0] = %d\n",*pt);
printf("number[1] = %d\n",*(pt+1));
printf("number[2] = %d\n",*(pt+2));
}

ไม่มีความคิดเห็น: