Upcoming SlideShare
×

# Pointer in C

427 views

Published on

Pointer in C

3 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
427
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
33
0
Likes
3
Embeds 0
No embeds

No notes for slide

### Pointer in C

1. 1. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
2. 2. Typing Speed: 18 Muhammed shafi shafi3949@gmail.com Shafi breeze Shafi breeze in.linkedin.com/in/profilena me 9961073949
3. 3. TOPIC Pointer in C
4. 4. What Are Pointers? A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location
5. 5. How to use Pointers? • There are few important operations, which we will do with the help of pointers very frequently. (a) we define a pointer variable (b) assign the address of a variable to a pointer and (c) finally access the value at the address available in the pointer variable. This is done by using unary operator * that returns the value of the variable located at the address specified by its operand. Following example makes use of these operations:
6. 6. Example of Pointers • #include <stdio.h> • • • • int main () { int var = 20; /* actual variable declaration */ int *ip; /* pointer variable declaration */ • ip = &var; /* store address of var in pointer variable*/ • printf("Address of var variable: %xn", &var ); • • /* address stored in pointer variable */ printf("Address stored in ip variable: %xn", ip ); • • /* access the value using the pointer */ printf("Value of *ip variable: %dn", *ip ); • • return 0; }
7. 7. When the above code is compiled and executed, it produces result something as follow Address of var variable: bffd8b3c Address stored in ip variable: bffd8b3c Value of *ip variable: 20
8. 8. NULL Pointers in C It is always a good practice to assign a NULL value to a pointer variable in case you do not have exact address to be assigned. This is done at the time of variable declaration. A pointer that is assigned NULL is called a null pointer.
9. 9. Example of NULL pointer #include <stdio.h> int main () { int *ptr = NULL; printf("The value of ptr is : %xn", ptr ); return 0; } Out put:The value of ptr is 0
10. 10. THE END Create by Shafi
11. 11. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550