halo saudara – saudara kali ini abang akan mebhasa entang pointer, pointer adalah petunjuk untuk lebih jelasnya silakan dilihat contoh – contohnya

 

Program Untuk menampilkan gambar X

void main()
{ int y,*c;
static int a[12][12]={
{1,0,0,0,0,0,0,0,0,0,0,1},
{0,1,0,0,0,0,0,0,0,0,1,0},
{0,0,1,0,0,0,0,0,0,1,0,0},
{0,0,0,1,0,0,0,0,1,0,0,0},
{0,0,0,0,1,0,0,1,0,0,0,0},
{0,0,0,0,0,1,1,0,0,0,0,0},
{0,0,0,0,1,0,0,1,0,0,0,0},
{0,0,0,1,0,0,0,0,1,0,0,0},
{0,0,1,0,0,0,0,0,0,1,0,0},
{0,1,0,0,0,0,0,0,0,0,1,0},
{1,0,0,0,0,0,0,0,0,0,0,1}};
c=&a;
for(y=0;y<144;y++)
{if(y%12==0&&y!=0&&y!=1)
printf(“\n”);
if(*(c+y))
printf(“%c”,219);
else printf(” “);}
getch();
}

 

  • Facebook
  • Twitter
  • Google+
  • Pinterest

2. Pointer menampilkan bilangan terurut

main()
{ int x,b,c;
puts(“input data yang akan diurutkan”);
scanf(“%d”,&x);
float z[x];
for(b=0;b<x;b++)
{printf(“Masukan bilangan %d = “,b+1);
scanf(“%f”,&z[b]);}
ulang:
puts(“data terbesar 1, data terkecil 2”);
scanf(“%d”,&c);
if(c==1) terbesar(&z,x);
else if (c==2)terkecil(&z,x);
else goto ulang;
puts(“setelah dirutukan”);
puts(“Menggunakan pointer”);
for(b=0;b<x;b++)
{printf(“Masukan bilangan %d = %g \n”,b+1,*(z+b));}

}

  • Facebook
  • Twitter
  • Google+
  • Pinterest