LEC20080912 - Introduction to Computer Programming...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Introduction to Computer Programming September 12, 2008 CSC180 Fall 2008, University of Toronto Compile a C program Required readings: all lecture notes and chapter 3. Work through all code examples in lecture notes, chapter 2 and 3. • Source files ⇒ object files ⇒ an executable file • Sources files contain C source code • Object and executable files contain machine code. • In an object file, references to the memory address of functions in other files are undefined. • How does gcc transform source files to an executable file? CSC180 Fall 2008, University of Toronto 1 1. preprocessing (include header files, expand macros) $ cpp read.c > read.i 2. compilation (from source code to assembly code) $ gcc -Wall -S read.i 3. I’ll talk the remaining two steps in subsequent lectures. CSC180 Fall 2008, University of Toronto 2 Formatted output: printf() • Standard Input/Output Library function printf() ’s prototype: extern int printf (__const char *__restrict __format, ...); • In library code, we frequently see identifiers beginning with underscores; but in your code, avoid doing this. • printf() converts internal values (stored in binary form) to characters, and displays them on standard output , under the control of format . In short, printf() prints formatted output. CSC180 Fall 2008, University of Toronto 3 • Standard output means screen by default. Standard output is actually a file pointed by stdout , which is opened implicitly when the program starts up. • printf(‘‘hello’’) is equivalent to fprintf(stdout, ‘‘hello’’) , where fprintf() has the following prototype: extern int fprintf (FILE *__restrict __stream, __const char *__restrict __format, ...); • Variable-length argument list: the number of arguments can vary • Let’s call the first argument format format string , and the following arguments format arguments ....
View Full Document

This note was uploaded on 01/10/2011 for the course CSC 180 taught by Professor Na during the Fall '01 term at University of Toronto.

Page1 / 23

LEC20080912 - Introduction to Computer Programming...

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

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