cs246-s11-001-june7

cs246-s11-001-june7 - CS 246 (Spring 2011) Section 1...

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

View Full Document Right Arrow Icon
CS 246 (Spring 2011) – Section 1 Tuesday 7 June Command-line Arguments, Preprocessor, and Debugging
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS 246 (Spring 2011) - Section 001 - Tuesday 7 June 2 Today's Agenda 2.11 Command-line Arguments 2.12 Preprocessor 2.13 Assertions 2.14 Debugging
Background image of page 2
CS 246 (Spring 2011) - Section 001 - Tuesday 7 June 3 2.11 Command-line Arguments Two overloaded prototypes for main int main() int main(int argc, char *argv[]) The second allows arguments to be passed into main when the program is executed argc is the number of arguments to main , including the name of the program Not explicitly passed in, automatically calculated argv is an array of pointers to C character strings (program name + arguments)
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS 246 (Spring 2011) - Section 001 - Tuesday 7 June 4 Command-line arguments (ctd.) Example ./program 32 hello int main(int argc, int *argv[]) { // argc is 3 // argv[0] is “./program\0” (string) // argv[1] is “32\0” // argv[2] is “hello” } Example on course site: IO.cc Converting string to integer and error checking Can use this as a template on your assignments
Background image of page 4
CS 246 (Spring 2011) - Section 001 - Tuesday 7 June 5 2.12 Preprocessor The preprocessor changes the content of your program before compilation The code you see is not what the compiler sees Three things we will look at Variables/substitution File inclusion Relevant for A3 Q2 Conditional inclusion
Background image of page 5

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

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

This note was uploaded on 12/08/2011 for the course CS 246 taught by Professor Wormer during the Spring '08 term at Waterloo.

Page1 / 18

cs246-s11-001-june7 - CS 246 (Spring 2011) Section 1...

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