In this part you will learn:
1. C syntax
3. Pointers declaration
4. Showing output
Whenever we declare variable our computer stores it in at a memory location in the memory. A unique address is assigned to every variable made by the user either its on run time or compile time. We use pointers to access those address whenever we want to and use the value that is stored on that particular address.
Pointer is a special kind of variable. Pointers are designed to store the memory address i.e. the address of another variable. Declaring a pointer is same as declaring any variable the difference is that between the type of variable and the name of the variable we place a asterisk ‘*’. The asterisk can be written either with the type or the name of the variable. Like this.
int* p or int *p (they both are the same).
When we write this statement this means that we declared a integer type pointer that will point to an integer type variable.
In C, especially when we are talking about pointer we call this symbol as dereference operator. Because when write this operator with any pointer that means that we are accessing the value of the address that is stored in that certain pointer.
When studying pointer you should also know about another symbol called ampersand ‘&’. You would have seen and used this symbol when you write the scanf() function. This symbol is used to access the address of any variable.
Swapping With Pointers
Open Dev C++ then File > new > source file and start writing the code below.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.