lec05

lec05 - Arrays and Strings CS 2022 Introduction to C...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Arrays and Strings CS 2022: Introduction to C Instructor: Hussam Abu-Libdeh Cornell University (based on slides by Saikat Guha) Fall 2009, Lecture 5 Arrays and Strings CS 2022, Fall 2009, Lecture 5
Background image of page 1

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

View Full DocumentRight Arrow Icon
Announcement I Assignment #1 released I due this Friday Sept. 11th at 11:59 PM I submit via CMS I Reminder: office hours today after class in 4139 Upson Hall Arrays and Strings CS 2022, Fall 2009, Lecture 5
Background image of page 2
Arrays I Contiguous memory I Type is same as element-pointer I Accessing array elements is syntactic sugar for pointer arithmetic I On the stack I Fixed-size (at compile time) I Compiler allocates I Compiler deallocates I On the heap I Variable size (malloc) I Explicit allocation/deallocation Arrays and Strings CS 2022, Fall 2009, Lecture 5
Background image of page 3

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

View Full DocumentRight Arrow Icon
void foo(int x) { int a[100]; int b[] = {0, 1, 0, 2, 3, 1}; int c[x]; // ERROR: Size must be const. a[0] = 10; a[5] = b[2]; a[100] = 10; // ERROR: Clobbering stack!! *(a + 1) = 20;
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 03/10/2011.

Page1 / 14

lec05 - Arrays and Strings CS 2022 Introduction to C...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online