| You are here: | About>Computing & Technology>C / C++ / C#> C> C Tutorials> Finishing the Lesson |
![]() | C / C++ / C# |
Elsewhere on the WebC Tutorial - Lesson Three - About CharsFinishing the Lesson![]() << Previous | Next Pointers can be quite challenging to learn. The diagram should provide a better insight.
The variable name (a pointer to a char) was located at address 0x007fe78. A pointer is 32 bits, ie. 4 bytes long and holds an address of the string which was 0x00408004. Addresses are always given in hexadecimal. The arrow shows what the pointer is pointing to, ie what is at the address in the pointer variable. At this address there were 13 bytes holding the string "David Bolton" with a terminating NULL, the same value as '\0'.
Arrays and Pointers are the SameModify the existing program and change the declaration of the pointer variable to this.char name[]="David Bolton"; Compile and run it and you should get the same as before. In C an array and a pointer are really the same thing. They refer to a memory address. Obviously you cannot change the array at runtime (as you can a pointer) but being able to use an array this way can be useful. That finishes this lesson. In the next lesson we'll start looking at expressions in C.
<< Previous | Next Elsewhere on the Web |
Las Vegas on a BudgetFind a BargainHotel DealsCheap EatsFree AttractionsEntertainment for Less |
All Topics | Email Article | Print this Page | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |



