Lecture20-LIN-10212019-Pointer.pdf - Computing I COMP.1010 Fall 2019 Lecture 20 Pointers in C(I By Sirong Lin PhD University of Massachusetts Lowell

Lecture20-LIN-10212019-Pointer.pdf - Computing I COMP.1010...

This preview shows page 1 - 13 out of 36 pages.

Computing I By: Sirong Lin, PhD University of Massachusetts Lowell COMP.1010, Fall 2019 Lecture 20: Pointers in C (I)
Image of page 1
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Upcoming Due Dates 2 Due Date Program 2 Design 10-23-2019 (W), in class Daily 16 10-23-2019 (W), 9:00pm Week 8 Reading F, 9:00am Pointer HW 10-25-2019 (F), before class Week 8 Practice Sun, 9:00pm Program 2 10-30-2019 (W), 9:00pm
Image of page 2
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Advising Week Meet your advisor to create the academic plan for Sping/Summer 2020 3
Image of page 3
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Pointers Concept Declaration Indirect access Arithmetic Pointers in function as output arguments 4
Image of page 4
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Review Memory Cell and Variable 5
Image of page 5
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Memory Cell — a unit in memory 6 ordered sequence of storage in memory each has a unique address always have contents (0s and 1s), can not be empty Address 1 0 1 1 0 1 1 0 2423452 0 1 1 1 0 0 1 1 2423453 1 1 1 1 0 0 1 0 2523689
Image of page 6
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Variable in C 7 variable: a named place in memory one variable may use several memory cells, e.g., an integer variable: 4 bytes a character variable: 1 byte
Image of page 7
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Variable in C (Cont’d) 8 name data e.g.,int data; data is variable name has an address: &data (address of data), is 2423452 always has a value, in two’s complement
Image of page 8
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Pointers pointer is a type of variable that stores memory address has all the properties of a variable name address value 9
Image of page 9
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Pointers (Cont’d) double *dPtr; dPtr is a pointer variable, it may store a memory address of a double type data read as “ dPtr is a pointer to a double can only store the address of a double type variable, but not an address of other data type 10
Image of page 10
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Pointers (Cont’d) double *dPtr; name: dPtr address: & dPtr value: initially a garbage value after assignment, it stores a valid address (e.g., of a variable) 11
Image of page 11
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Pointers (Cont’d) A pointer is a named place in memory that stores the address of a data item.
Image of page 12
Image of page 13

You've reached the end of your free preview.

Want to read all 36 pages?

  • Fall '15

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors