DOC PREVIEW
TRINITY CSCI 1320 - Lecture Notes

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1File I/O9-28-20062Opening Discussion■What is recursion? What things can recursion do that standard loops can't? Why can it do those things?■Let's write Fibonacci using a recursive function and trace it.■Do you have any questions about the assignment?■Do you have any questions about the midterm?3Dealing with Files■Last time we discussed how adding file manipulation can make our programs much more powerful.■The functionality we want is actually part of the stdio library.■We represent a file by declaring a variable of type FILE*. The asterisk means it is a points. We'll learn exactly what that means later on.■Use fopen to initialize your FILE*. It takes a file name and a string giving the mode. The mode is a combination of the characters r|w|a, t|b, [+].■When you are done with the file you need to pass the FILE* to the fclose function.4Writing and Reading■Once you have opened the file you need to be able to either write to it or read from it. We do this with functions very similar to printf and scanf. (Actually, printf and scanf are have aliases for these other functions.)■The fprintf and fscanf functions take a FILE* as their first argument. The rest of the arguments are just like printf and scanf.■Let's use this to get one of our programs to read from a file or write to a file.5Standard Streams■There are actually standard names for file streams that represent standard input and output.■The name stdin can be used to read from standard input.■The name stdout can be used to write to standard output.6Coding■Let's write something more significant and potentially a bit more fun that will use some files.■Remember that the real benefit of files is to store things between uses of a program.7Arrays■After the midterm we will be talking about arrays. These structures give us a way to hold multiple things us the same type.■Consider if I wanted you to write a program to read in 100 numbers and do many different things with them. How would you do that given what we have learned so far? It's possible, but it definitely wouldn't be pretty.8Minute Essay■Remember that the midterm is next Tuesday. I plan to have a review session starting at 4:30 on Monday. I don't prepare anything for the review sessions. I expect you to show up with questions that you would like me to answer.■Also remember that assignment #3 is due tonight. I should be around some this afternoon to answer


View Full Document

TRINITY CSCI 1320 - Lecture Notes

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?