Algorithm & programming part VII (Data Structure)

This is 7th part of our meeting. In this meeting we’re gonna talk about pointer. But, before we go to the point , we have to know first about static and dynamic variable. As we know before , we only use static variable to save the data and it can’t be changed when the program is executed. So, static variable is a variable which is the size and sequence can’t be changed when the program is executed. And it is always shown by identifier. On the other hand, Dynamic variable is more flexible, because we can change it’s size and sequence even though the program is executed. And especially for dynamic variable, it’s always shown by pointer.

Pointer is very important for managing memory in a big program. A programmer won’t be a great one if he/ she still doesn’t master pointer first. Because it’s a basic in a structure of a big program.

On the other side, if we wrong to use pointer, it’s gonna mash up our program. It’s usually called access violation.

In this part and later, I am not gonna make sample from Pascal programming language. Because after this i’d like to focus in C programming language. Alright, let’s declare the pointer now.

For example I wanna declare a pointer In integer type.

Int *p;

it means that I declare a dynamic variable (pointer) with type integer. After this, in main program, we have to order an allocation of memory for the pointer. This Is the way

p=(int*)malloc(sizeof (int));

it means that we have ordered an area as large as integer (2 byte) and we save the address in pointer p

oh…ya I almost forget that malloc function is only exist in stdlib header file so we have to declare it first in the beginning of the program.

Here is the example pointer to integer

#include <stdio.h>
#include <stdlib.h>

int main(){
int a,*p;

printf("Program Pointer Ke Integer\n");
puts("Masukkan sebuah angka ke variabel A = ");scanf("%d",&a);
printf("Hasil peng-Copy-an data dari variabel A ke pointer P adalah = %d\n",*p);
return (0);

Here is the example pointer to struct


#include <stdio.h>
#include <stdlib.h>

typedef struct data{
char lokasi[20];
int luas;

typedef struct data node;
node *p;

int main(){

system ("clear");
printf("Masukkan nama lokasi sebuah tempat = ");scanf("%s",p->lokasi);
printf("Masukkan luas lokasi tempat tersebut= ");scanf("%d",&p->luas);
printf("Sebelum pointer P dibuat NULL\n");
printf("Nama lokasi tersebut adalah = %s\n",p->lokasi);
printf("Nama luas tersebut adalah = %d\n",p->luas);
printf("Sesudah pointer P dibuat NULL\n");
printf("Nama lokasi tersebut adalah = %s\n",p->lokasi);
printf("Nama luas tersebut adalah = %d\n",p->luas);
return (0);



12 thoughts on “Algorithm & programming part VII (Data Structure)

  1. branchenverzeichnis online 10/24/2010 at 4:59 pm Reply

    yeah,I just thought you might want to know that your blog is messed up when you view it on my iphone. I?m not sure if it has something to do with my phone?s browser or your website? just saying…

    • xaxioza 10/25/2010 at 4:30 pm Reply

      I’ve checked the problem, and the error occured because of your iphone / browser didn’t support language programming which is used in my BLog

  2. suchmaschine 10/27/2010 at 2:32 pm Reply

    I usually don’t post in Blogs but your blog forced me to, amazing work.. beautiful …

    • xaxioza 10/27/2010 at 4:58 pm Reply

      Thank you…
      I usually post my activity and anything that i’ve learned in my blog to share with the others

  3. Viagra rezeptfrei 11/02/2010 at 1:43 am Reply

    There is obviously a lot to know about this. I think you made some good points in Features also.
    Keep working ,great job!

    • xaxioza 11/02/2010 at 9:07 am Reply

      Thank you so much

  4. Potenzmittel bestellen 11/02/2010 at 2:42 am Reply

    To start earning money with your blog, initially use Google Adsense but gradually as your traffic
    increases, keep adding more and more money making programs to your site.
    thanks !! very helpful post!

    • xaxioza 11/03/2010 at 5:57 pm Reply

      Thank you for your suggestion . I’m gonna do it better

  5. pc games 11/02/2010 at 4:27 pm Reply

    I don’t usually reply to posts but I will in this case.
    my God, i thought you were going to chip in with some decisive insght at the end there, not leave it
    with ‘we leave it to you to decide’.

    • xaxioza 11/15/2010 at 12:04 pm Reply

      Thank u. I’ll be better next time

  6. pc spiele neuheiten 11/02/2010 at 5:29 pm Reply

    Total Control Marketing Review- Great piece of details that you?ve received on this website article. Hope I could possibly get some a lot more of the stuff on your own web site. I will arrive again.

    • xaxioza 11/15/2010 at 12:05 pm Reply

      Thank you . I hope you’ll enjoy in in my website

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: