C_lecture_1

C_lecture_1 - CS 11 C track: lecture 1 n Preliminaries n...

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

View Full Document Right Arrow Icon
CS 11 C track: lecture 1 n Preliminaries n Need a CS (CMS) cluster account n http://www.cs.caltech.edu/ cgi-bin/sysadmin/account_request.cgi n Need to know UNIX n ITS tutorial linked from track home page n Track home page: n www.cs.caltech.edu/courses/cs11/material/c/mike
Background image of page 1

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

View Full DocumentRight Arrow Icon
Assignments n 1st assignment is posted now n Due one week after class, midnight n Grading policy: see "admin page" linked from track home page
Background image of page 2
Other administrative stuff n Again, see admin web page: http://www.cs.caltech.edu/courses/cs11/material/ c/mike/admin.html n Covers how to submit labs, collaboration policy, grading, etc.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Main textbook n C: A Software Engineering Approach, 3rd ed. by Peter A. Darnell, Philip E. Margolis n Thorough, readable
Background image of page 4
Supplemental textbook n Kernighan and Ritchie: The C Programming Language, 2nd. ed. n 1st edition NOT acceptable n "ANSI C" n Good for reference
Background image of page 5

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

View Full DocumentRight Arrow Icon
C: pros and cons n What C is good at n low-level programming n speed and memory efficiency n portability (sorta) n Bad things about C n unsafe!!! n low level of abstraction
Background image of page 6
Getting started (1) n The "hello, world!" program: #include <stdio.h> int main(void) { printf("hello, world!\n"); return 0; }
Background image of page 7

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

View Full DocumentRight Arrow Icon
Getting started (2) n Make this into a file called hello.c using a text editor n e.g. emacs , vi , nedit , pico n Compile into a program and run: % gcc hello.c -o hello % hello hello, world! % n Woo hoo!
Background image of page 8
Source code to executable (1) n What you write is called "source code" n Two kinds of source code files: n regular code (files end in " .c ") n header files (files end in " .h ") n Compiler turns source code into "object code" n (files end in " .o ") n Linker turns object code file(s) into executable (no special file suffix)
Background image of page 9

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

View Full DocumentRight Arrow Icon
Source code to executable (2) n The program gcc is both a compiler and a linker n When you do this: % gcc hello.c -o hello n Then gcc n compiles hello.c to hello.o n links hello.o with system libraries n outputs the binary executable program hello n removes hello.o
Background image of page 10
Source code to executable (3) n You can do each step individually: % gcc -c hello.c (compile only) % gcc hello.o -o hello (link only) n In this case, hello.o is not removed n Sequence: n compiling : source code to object code n linking : object code to binary executable
Background image of page 11

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

View Full DocumentRight Arrow Icon
The C language - overview n Programs are built up of functions n Functions n take in arguments n compute something n return a result n The main() function n is where program execution starts
Background image of page 12
Data types (1) n
Background image of page 13

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

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/21/2012 for the course CS 11 taught by Professor Pinkston,d during the Winter '08 term at Caltech.

Page1 / 60

C_lecture_1 - CS 11 C track: lecture 1 n Preliminaries n...

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

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