{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

05-intro-functions_in_C

05-intro-functions_in_C - Computer Science 136 Elementary...

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

View Full Document Right Arrow Icon
Computer Science 136: David R. Cheriton School of Computer Science Elementary Algorithm Design and Data Abstraction Winter 2012 Lecture 5 – An Introduction to C We introduce the C programming language. C is a general purpose programming language developed by Dennis Ritchie in 1969-73, for use in the UNIX operating system. Both C and UNIX are still extremely important now. C exposes the machine architecture and memory model like few other languages and hence is extremely important in our understanding of computer programming. CS 136 – Winter 2012 05 – Introduction to C 1/35
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
Intro to C C is often referred to as a “System implementation language” Brian Kernighan, Dennis Ritchie and others developed the UNIX operating system in the early 1970s, and developed C as its implementation language. UNIX was the first operating system (OS) that made it off mainframes, to minicomputers, and then to microcomputers C is considered a “low-level” language, especially in its early versions. It allows direct access to the machine, and often reflects the idiosyncrasies of the computers of the 1970s! This means you can easily “crash” a program using C, possibly even your computer. CS 136 – Winter 2012 05 – Introduction to C 2/35
Image of page 2
Intro to C “C gives you enough rope to shoot yourself in the foot.” A good reference is essential: K. N. King: C Programming, A Modern Approach. We will take an idiomatic (as opposed to systematic) approach to learning C in class. You must follow up with reading the King text. Start with: Chapter 2: “C Fundamentals” Chapter 15: “Writing Large Programs” CS 136 – Winter 2012 05 – Introduction to C 3/35
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
C source files and modules C has primitive version of Racket’s modules, based solely on source files. CS 136 – Winter 2012 05 – Introduction to C 4/35
Image of page 4
C source files and modules C has primitive version of Racket’s modules, based solely on source files. Implementation code goes in a file, e.g. foo.c //This is a function that doubles an integer int foo ( int i) { return i + i; } CS 136 – Winter 2012 05 – Introduction to C 4/35
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
C source files and modules C has primitive version of Racket’s modules, based solely on source files. Implementation code goes in a file, e.g. foo.c //This is a function that doubles an integer int foo ( int i) { return i + i; } Interface/specification goes in a different file foo.h , called a header file. int foo( int ); CS 136 – Winter 2012 05 – Introduction to C 4/35
Image of page 6
C source files and modules C has primitive version of Racket’s modules, based solely on source files. Implementation code goes in a file, e.g. foo.c //This is a function that doubles an integer int foo ( int i) { return i + i; } Interface/specification goes in a different file foo.h , called a header file. int foo( int ); Somebody (the client) wants to use foo? #include "foo.h" ...
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
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