Pointer in C
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Pointer in C

Pointer in C

Statistics

Views

Total Views
598
Views on SlideShare
598
Embed Views
0

Actions

Likes
1
Downloads
18
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Pointer in C Presentation Transcript

  • 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. Typing Speed: 18 Muhammed shafi shafi3949@gmail.com Shafi breeze Shafi breeze in.linkedin.com/in/profilena me 9961073949
  • 3. TOPIC Pointer in C
  • 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. 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. 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. 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. 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. 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. THE END Create by Shafi
  • 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