C_lecture_1

C_lecture_1 - CS 11 C track: lecture 1 Preliminaries Need a...

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

View Full Document Right Arrow Icon
CS 11 C track: lecture 1 Preliminaries Need a CS cluster account http://www.cs.caltech.edu/ cgi-bin/sysadmin/account_request.cgi Need to know UNIX ITS tutorial linked from track home page Track home page: 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 1st assignment is posted now Due one week after class, midnight Late penalty: 1 mark/day Redos
Background image of page 2
Redos 1st redo = 1 mark off 2nd redo = 1 to 2 more marks off 3rd redo = 1 to 3 more marks off No 4th redo! Grade - 6 mark penalty
Background image of page 3

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

View Full DocumentRight Arrow Icon
Passing Need average of 7/10 on labs 8 labs 56/80 marks
Background image of page 4
Other administrative stuff See admin web page: http://www.cs.caltech.edu/courses/cs11/material/ c/mike/admin.html Covers how to submit labs, collaboration policy, grading, etc.
Background image of page 5

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

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

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

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

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

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

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

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

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

View Full DocumentRight Arrow Icon
The C language - overview Programs are built up of functions Functions take in arguments compute something return a result The main() function is where program execution starts
Background image of page 14
Data types (1) All data in C has to have a specified
Background image of page 15

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

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

Page1 / 62

C_lecture_1 - CS 11 C track: lecture 1 Preliminaries Need a...

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

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