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

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

View Full Document Right Arrow Icon
CS 11 C track: lecture 1 ± Administrivia ± 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
Main textbook ± C: A Software Engineering Approach, 3rd ed. by Peter A. Darnell, Philip E. Margolis ± Thorough, readable
Background image of page 3

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

View Full DocumentRight Arrow Icon
Supplemental textbook ± Kernighan and Ritchie: The C Programming Language, 2nd. ed. ± 1st edition NOT acceptable ± "ANSI C" ± Good for reference
Background image of page 4
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 5

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

View Full DocumentRight Arrow Icon
Getting started (1) ± The "hello, world!" program: #include <stdio.h> int main(void) { printf("hello, world!\n"); return 0; }
Background image of page 6
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 7

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

View Full DocumentRight Arrow Icon
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 8
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 hello ± removes hello.o
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 (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 10
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 11

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

View Full DocumentRight Arrow Icon
Data types (1) ± All data in C has to have a specified type ± Examples: ± int (integer) ± char (character) ± float or double (approximate real number) ± others ± Variables hold data of a particular type only ± Variables must be declared before use
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/30/2008 for the course C CMPE 150 taught by Professor Tuna during the Spring '08 term at Boğaziçi University.

Page1 / 57

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

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

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