CSC 253 Lecture 9.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Dynamic Memory Allocation (also see pointers lectures) -L. Grewe.
Function with Output Parameters 4 We have seen that functions can return a single value or no value (void return type) 4 It is quite often useful to be.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Week 6 - Wednesday.  What did we talk about last time?  Exam 1!  And before that…  Review!  And before that…  Arrays and strings.
19&20-2 Know how to declare pointer variables. Understand the & (address) and *(indirection) operators. Dynamic Memory Allocation Related Chapter: ABC.
Week 3 - Friday.  What did we talk about last time?  Operations on boolean values  !, &&, ||  Operations on char values  +, -  Operations on String.
1 CSC103: Introduction to Computer and Programming Lecture No 19.
1 CSC103: Introduction to Computer and Programming Lecture No 17.
Spring 2008 Mark Fontenot CSE Honors Principles of Computer Science I Note Set 10.
Background Survey Answers Operating Systems CS 550 Spring 2016 Kenneth Chiu.
Arrays Chapter 7.
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
I/O Streams File I/O 2-D array review
Dynamic Allocation Review Structure and list processing
Java for Beginners Level 6 University Greenwich Computing At School
CSC 495/583 Topics of Software Security Stack Overflows
Arrays Low level collections.
Pointers & Arrays.
© 2016 Pearson Education, Ltd. All rights reserved.
Numeric Arrays Numeric Arrays Chapter 4.
An introduction to arrays
CS1010 Discussion Group 11 Week 6 – One dimensional arrays.
Week 7 Part 2 Kyle Dewey.
Computer Systems and Networks
More Recursion.
Programming Languages and Paradigms
Waves!.
This pointer, Dynamic memory allocation, Constructors and Destructor
CS 240 – Lecture 16 Structs, Struct Arrays, Struct Pointers, sizeof, malloc, free, void pointer.
CSC 253 Lecture 8.
CSC 253 Lecture 13.
Strings, Line-by-line I/O, Functions, Call-by-Reference, Call-by-Value
Announcements Homework #7 due Monday at 3:00pm
CSC 253 Lecture 8.
CS 2308 Exam I Review.
Arrays.
CS 179: Lecture 12.
Why arrays are cool 4/25/2007.
CSC 253 Lecture 7.
CSC 495/583 Topics of Software Security Format String Bug (2) & Heap
Dynamic Memory Allocation (and Multi-Dimensional Arrays)
CS2011 Introduction to Programming I Arrays (I)
Arrays ICS2O.
Arrays Chapter 7.
Chapter 16 Pointers and Arrays
Your questions from last session
CS111 Computer Programming
CS150 Introduction to Computer Science 1
EE 312 Exam I Review.
CS150 Introduction to Computer Science 1
TUTORIAL 7 CS 137 F18 October 30th.
CSE 143 Lecture 3 Implementing ArrayIntList reading:
Pointers & Arrays.
CSC1401 Input and Output (with Files)
CS150 Introduction to Computer Science 1
Chapter 10-1: Dynamic Memory Allocation
Assignment due Write a program the generates a random integer expression, presents the two operands and the result to the user, and asks the user to tell.
CSCE 206 Lab Structured Programming in C
Block I/O fread and fwrite functions are the most efficient way to read or write large amounts of data. fread() – reads a specified number of bytes from.
Programming Arrays.
Arrays and Pointers CSE 2031 Fall July 2019.
CS 144 Advanced C++ Programming April 30 Class Meeting
ㅎㅎ Fourth step for Learning C++ Programming Call by value
Week 7 - Friday CS222.
Arrays and Pointers.
Chapter 6 - Arrays Outline Multiple-Subscripted Arrays.
Dynamic Data Structures
Introduction to C CS 3410.
Presentation transcript:

CSC 253 Lecture 9

malloc and calloc Let’s take Jason’s ptr4.c and change it to allocate regions larger than 1 word to incorporate a printing function like we wrote last week to allocate something other than ints. Let’s print the start address and ending address of each array.

Why malloc is dangerous … If our array gets out of bounds, we can overwrite an element of another array. How can we calculate the subscript of one array that will smash the zeroth element of the next array?

Binary file I/O Let’s try the program for writing a file, ptr6.c. Let’s try the program for reading a file, ptr5.c. Let’s try to put the output in a more general format, like a memory dump.

File manipulation Let’s write a program that determines the length of a binary file. Let’s change the program to set the position to somewhere else in the file. Let’s change the program to set the position to an arbitrary place in the file, and then report how far it is from the end.