




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An introduction to pointers in c programming language. It covers the concept of pointer variables, their declaration, assignment, access, and two uses of the pointer operator. It also includes examples and explanations of the & and * operators.
Typology: Slides
1 / 28
This page cannot be seen from the preview
Don't miss anything!
Overview
int x = 5; int *countptr; countptr = &x;
Assigment in Pictures int x = 5; x
int *countptr; countptr
countptr = &x; countptr
x
countptr
Initialising a Pointer
float *yptr; xptr = NULL; yptr = NULL;
printf("...", *countptr);
int a = 3; *gptr; gptr = &a; *gptr = 7;
The & and * Operators Fig. 7. #include <stdio.h> int main() { int a = 7 ; int aptr; aptr = &a; / continued on next slide */
printf("Address of a is %lu\n", &a); printf("Value of aptr is %lu\n\n", aptr); printf("Value of a is %d\n", a); printf("Value of aptr is %d\n\n", aptr); printf("%s\n", "Proving that * and & are complements of each other."); printf("&aptr = %lu\n", &aptr); printf("*&aptr = %lu\n", *&aptr); return 0; }
Declarations and Initialisations int i = 3, j = 5, *p = &i, *q = &j, *r; double x; Expression Equivalent Expression Value p == &i p == (&i) 1 (true) p = i + 7 p = (i + 7) illegal **&p *p (^3) r = &x r = (&x) illegal