[C Programming] What's the pointer? (1)

1. Memory is divided into some blocks.





















2. In each block, it has a certain address. 
 - It looks like 0x123FFADE





















3. We can approach this block's address, and make this block has a some value.

4. But It's too bothersome! 
 ex) approach 0xDAFFADBC.. and make it has a integer value 38 , approach 0xAABFF23A .. and make it has a character value 'c'.

5.To make a life easier, we use a 'variable' not to use bothersome memory addresses.

 ex) 
int radius = 15;
int length = 25;

* in picture, like this :


We put a name on the memory address, the name is variable exactly.

Through it, We can approach memory address by just calling the variable, radius.

like this : printf("%d",radius);

It's easy. right?

6. We made a variable, 'radius', and put integer 15 as a value of it. and assume memory address is 0xAA13BAFF. 

7. We can also make a variable, 'word', and put character 'c' as a value of it. and assume it's memory address is 0xAD22FADD.

8. Ok, we can have a integer value, character value..

9. Then, can we have a memory address as a value?

10. Of course, you can!! 
And, it's the "pointer variable" that has a memory address as a value of it. That's just a pointer. It's done.
You've learnt a pointer!
It's just a variable that has a memory address as a value of it.

Hmm.. Ok, so why we need a memory address as a value of a variable?

WHY WE NEED A POINTER?

We'll learn about it later post.

댓글 없음:

댓글 쓰기