GridVids
Sign in with YouTube

C Programming tutorial #14 Null Pointer, Typecasting, Pointer Arithmetic

Mark watched
Don't Miss
Hide
Open in popup Open on YouTube

Xoviabcs 8 years ago
Chapters

C Programming tutorial #14 pointer variable, Dereferencing operator, Null pointer, Pointer types, Typecasting, Pointers and arrays, Pointer arithmetic.

- The "dereferencing operator" is the asterisk and it is used as follows: *p= 7; - will copy 7 to the address pointed to by p. Thus if p "points to" k, the above statement will set the value of k to 7. - Using '*' is a way of referring to the value of that which p is pointing to, not the value of the pointer itself.

NULL pointers: - Values of a pointer variable: - Usually the value of a pointer variable is a pointer to some other variable - A null pointer is a special pointer value that is known not to point anywhere. - No other valid pointer, to any other variable, will ever compare equal to a null pointer ! - Predefined constant NULL, defined in stdio.h - Good practice: test for a null pointer before inspecting the value pointed !

Pointer types: - C provides for a pointer of type void. We can declare such a pointer by writing: void *vptr; - A void pointer is a generic pointer. For example, a pointer to any type can be compared to a void pointer - Typecasts can be used to convert from one type of pointer to another under the proper circumstances

Pointers and arrays: - In C, there is a strong relationship between pointers and arrays - Any operation that can be achieved by array subscripting can also be done with pointers C Programming Tutorial/ Lectures/ Course with Data Structures & Algorithms @ https://goo.gl/K6VbgL Machine Learning Complete Tutorial/Lectures/Course from IIT (nptel) for GATE @ https://goo.gl/AurRXm Discrete Mathematics for Computer Science for GATE @ https://goo.gl/YJnA4B (IIT Lectures for GATE) Best Programming Courses @ https://goo.gl/MVVDXR Operating Systems Lecture/Tutorials from IIT for GATE CSE @ https://goo.gl/GMr3if MATLAB Tutorials for GATE @ https://goo.gl/EiPgCF