{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

slides-2 - Data Structures CSCI 102 Housekeeping Assignment...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Additional rule for exam regrades To be eligible for exam regrades , you must write your entire exam in ink 1 Data Structures - CSCI 102 Copyright © William C. Cheng Housekeeping (1/18/2011) Assignment and exam regrades Submit within 2 weeks of initial grade notification
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Pointers 2 Data Structures - CSCI 102 Copyright © William C. Cheng Pointers (Ch 13) Must remember to clean up after yourself Usage can be error prone Why worry? Mistakes don’t always show up right away Mistakes can have weird symptoms Memory bugs are hard to understand & fix (even for professionals)
Image of page 2
Let’s see some code 3 Data Structures - CSCI 102 Copyright © William C. Cheng Coding Exampls Assigning and passing variables by value Assigning and passing variables by references Assigning and passing pointers Displaying the addresses of variables Debuggers gdb (see quick summary on next slide) ddd (on aludra and nunki)
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
print field after every cmd: (gdb) display f.BlockType assignment: (gdb) set f.BlockType=0 print field: (gdb) print f.BlockType printf(): (gdb) printf "%02x\n",buf[0] single-step at same level: (gdb) next single-step into a function: (gdb) step continue: (gdb) cont clear breakpoint: (gdb) clear run program: (gdb) run compile program with: start debugging: gdb hw1 -g set breakpoint: (gdb) break foo.c:123 The debugger is your friend! Get to know it! quit: (gdb) quit stack trace: (gdb) where 4 Data Structures - CSCI 102 Copyright © William C. Cheng Notes on gdb
Image of page 4
5 Data Structures - CSCI 102 Copyright © William C. Cheng variables.cpp /* * 1) Demonstrate static, stack, heap variables. * 2) Declare a static int. * 3) Write a function that returns the square of a number. * 4) In main(), use a stack variable, call square() and print * the number and its square. Call malloc() to create an * integer, call square() and print the number and its square.
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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