09+-+Argv+and+IO - 5/17/2009 Announcements Ve 280...

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

View Full Document Right Arrow Icon
5/17/2009 1 Input and Outpu Ve 280 Programming and Introductory Data Structures Input and Output Announcements y Project 2 files were messed up on Sakai – they should now be correct y There is no tree_find() function y You must implement the contained_by() function y You have one extra day to finish your code (due Tues, 11:59pm) y If you submitted something incorrectly due to this, notify me ASAP so I can return your code and you can resubmit y DO NOT write a main() in your project 2 submission file y Your code will not compile!!! Intro to I/O The basics y So far, we've considered programs that always do exactly the same thing. y We haven't really examined I/O in great detail nor have we tried passing arguments to the programs we are running tried passing arguments to the programs we are running. y For example, consider using the submit280 program from EECS 280 at UM to submit your project 2 solution: submit280 2 p2.cpp Intro to I/O The basics submit280 2 p2.cpp y The first word, submit280 , is the name of the program to run. y The second and third words are argument to the submit280 The second and third words are arguments to the program. y These arguments are passed to submit280 for its consideration, much as arguments are passed to functions. y The shell (the program to which you type commands) collects arguments and passes them to the programs it executes. Intro to I/O The basics y Unlike functions, programs have no specific “type signature” for the arguments they expect and it’s up to the program to interpret what it is passed correctly. y The first challenge is that a program can’t know in advance how many arguments it will be passed. So it has to be written to be generic with respect to number of arguments. y We’ve already seen one type which enables us to pass an argument of unknown size to a function. y Question : What is it? Intro to I/O The basics y Unlike functions, programs have no specific “type signature” for the arguments they expect and it’s up to the program to interpret what it is passed correctly. y The first challenge is that a program can’t know in advance how many arguments it will be passed. So it has to be written to be generic with respect to number of arguments. y We’ve already seen one type which enables us to pass an argument of unknown size to a function. y Question : What is it? Answer : Arrays
Background image of page 1

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

View Full DocumentRight Arrow Icon
5/17/2009 2 Intro to I/O The basics y Recall the function to sum up the elements of an array. int sum(int a[], unsigned int size); y It took two arguments as input: 1. The array 2. The array’s size (i.e. the number of elements in the array). y Arguments are passed to programs as an array too. y Since each argument is just a sequence of characters, this array is an array of C-strings. Input/Output argv y Remember, a C-string is itself an array of char, so what we haveis an array of arrays.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/26/2009 for the course EECS 280 taught by Professor Jeff during the Summer '09 term at University of Michigan-Dearborn.

Page1 / 7

09+-+Argv+and+IO - 5/17/2009 Announcements Ve 280...

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

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