POINTERS IN C. Introduction  A pointer is a variable that holds a memory address  This address is the location of another object (typically another.

Slides:



Advertisements
Similar presentations
Copyright © 2002 Pearson Education, Inc. Slide 1.
Advertisements

Chapter 10 Pointers and Dynamic Arrays. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives Pointers Pointer variables.
Data Structures Using C++ 2E
Introduction to Programming Lecture 15. In Today’s Lecture Pointers and Arrays Manipulations Pointers and Arrays Manipulations Pointers Expression Pointers.
Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
A pointer is the memory address of a variable. A memory address is a physical location within a system’s memory space. A pointer variable is variable used.
Data Structures (Second Part) Lecture 2 : Pointers Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University.
Dynamic Memory Allocation (also see pointers lectures) -L. Grewe.
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Pointers.
Introduction to Programming Lecture 39. Copy Constructor.
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
CS 141 Computer Programming 1 1 Pointers. Pointer Variable Declarations and Initialization Pointer variables –Contain memory addresses as values –Normally,
Introduction of Memory Allocation. Memory Allocation There are two types of memory allocations possible in c. Compile-time or Static allocation Run-time.
Objectives Learn about objects and reference variables Explore how to use predefined methods in a program.
Pointers and Dynamic Memory Allocation. Dynamic Data Suppose we write a program to keep track of a list of students How many student records should we.
Introduction to Data Structure, Spring 2007 Slide- 1 California State University, Fresno Introduction to Data Structure Memory Allocation Ming Li Department.
1 Lecture 25:Pointers Introduction to Computer Science Spring 2006.
Arrays in C++ Numeric Character. Structured Data Type A structured data type is a type that stores a collection of individual components with one variable.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Dynamic Memory Allocation 9.8.
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Pointers & Dynamic Arrays Shinta P.
C++ Data Types Structured array struct union class Address pointer reference Simple IntegralFloating char short int long enum float double long double.
Chapter 9 Pointers and Dynamic Arrays (9.1). Pointers A variables which holds the memory address for a variable of a specific type. Call-by-Reference.
Pointers in C++. 7a-2 Pointers "pointer" is a basic type like int or double value of a pointer variable contains the location, or address in memory, of.
C++ Pointers Review. Overview  What is a pointer  Why do I care?  What can be 'pointed to'?  Example.
Welcome to Concepts Pointer Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्जेण्डर )PGT(CS) KV JHAGRAKHAND.
Welcome to Concepts of Pointers. Prepared by:- Sumit Kumar PGT(Computer Science) Kv,Samba.
Pointers in C++. Topics Covered  Introduction to Pointers  Pointers and arrays  Character Pointers, Arrays and Strings  Examples.
Revision on C++ Pointers TCP1201: 2013/2014. Pointer Basics  Why pointer is important? 1. Reference/Point to existing data without cloning the data.
1 2/2/05CS250 Introduction to Computer Science II Pointers.
P OINTERS A pointer is an address All data is stored in memory in some location that is indexed with an address Can refer to variables by name or by memory.
Scis.regis.edu ● CS-362: Data Structures Week 6 Part 2 Dr. Jesús Borrego 1.
POINTERS IN C Pointer Basics, Pointer Arithmetic, Pointer to arrays and Pointer in functions.
Pointers 1. Introduction Declaring pointer variables Pointer operators Pointer arithmetic 2 Topics to be Covered.
Data Structures in C++ Pointers & Dynamic Arrays Shinta P.
Pointers in C by Dr P.Padmanabham Professor (CSE)&Director Bharat Institute of Engineering &Technology Hyderabad Mobile
1 CSC103: Introduction to Computer and Programming Lecture No 17.
Pointers. Introduction to pointers Pointer variables contain memory addresses as their values. Usually, a variable directly contains a specific value.
CSCI 125 & 161 / ENGR 144 Lecture 16 Martin van Bommel.
Basic Concepts:- Invalid use of Address Operator &75 &(‘a’) &(a+b)
Pointers A variable that holds an address value is called a pointer variable, or simply a pointer.  What is the data type of pointer variables? It’s not.
Integer VariablestMyn1 Integer Variables It must be possible to store data items in a program, and this facility is provided by variables. A variable is.
Overview Working directly with memory locations is beneficial. In C, pointers allow you to: change values passed as arguments to functions work directly.
Introduction to Programming Using C
Pointers Introduction
© 2016 Pearson Education, Ltd. All rights reserved.
Pointers and Pointer-Based Strings
C++ Interlude 2 Pointers, Polymorphism, and Memory Allocation
Chapter 9 Pointers Objectives
Pointers Psst… over there.
Basic notes on pointers in C
Pointer Data Type and Pointer Variables
Pointer Basics Psst… over there.
CSC 253 Lecture 8.
CSC 253 Lecture 8.
Dynamic Memory A whole heap of fun….
CSCE 206 Lab Structured Programming in C
Pointers and Pointer-Based Strings
ECE 103 Engineering Programming Chapter 35 C Pointers, Part 1
C Programming Lecture-8 Pointers and Memory Management
POINTER CONCEPT 4/15/2019.
C Programming Pointers
Creating and Using Pointer Variables in C++ By: Ed Brunjes
Pointer Data Type and Pointer Variables
Pointer Basics Psst… over there.
Pointer Data Type and Pointer Variables
CSCE 206 Lab Structured Programming in C
POINTER CONCEPT 8/3/2019.
Introduction to Pointers
Presentation transcript:

POINTERS IN C

Introduction  A pointer is a variable that holds a memory address  This address is the location of another object (typically another variable) in memory  Use of pointers is crucial to successful C programming  Pointers support dynamic allocation  Pointer containing an invalid value can cause your program to crash

Declaring pointer variables  A pointer declaration consists of a base data type, an *, and the variable name.  Data type *name;  Ex. : int *var1;  int * - Any address that it holds points to an integer  Pointer Operators  * and &.  & is a unary operator that returns the memory address of its operand

Accessing address using Pointer  Example  int *m, count=10,q;  m = &count; //stores memory address of count into m  q = *m; // stores values located at the address 10