APS106H1 Study Guide - Midterm Guide: Temporary File, Binary File, Scanf Format StringPremium


Department
Applied Science and Engineering
Course Code
APS106H1
Professor
Reza Kholghy, Li Shu, Chris Beck, Markus Bussmann
Study Guide
Midterm

This preview shows pages 1-3. to view the full 32 pages of the document.
University of Toronto (St.George)
APS106 - Fundamentals of Computer
Programming
Professor: Reza Kholghy, Li Shu , Chris Beck, Markus
Bussmann
Midterm
Exam Guide

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

Subscribers Only
Topics Included:
1. Streams
2. File Operations
3. Formatted I/O
4. Character I/O
5. Line I/O
6. Defining and Calling functions
7. Function Declarations
8. Arguments
9. Return Statement
10. Program Termination
11. Recursion
12. One-Dimensional Arrays
13. Multidimensional Arrays
14. Variable-length Arrays
15. One-Dimensional Arrays
16. Multidimensional Arrays
17. Variable-length Arrays

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

Subscribers Only
Chapter 22 Input/Output
22.1 Streams
Streams: means any source of input or any destination for output. E.g. keyboard,
screen.
<stdio.h>: stream header, the primary repository of input/output functions.
File Pointer: used to access a stream in a C program, which has type FILE*. Certain
streams are represented by file pointers with standard names
Example:
Standard Streams: <stdio. h> provides three standard streams: stdin, stdout,
stderr;
These streams are ready to use, don’t need to declare, open or close them.
Redirection: Functions like printf, scanf, putchar,getchar,puts and gets, obtain input
form stdin and output to stdout. Generally, stdin represents the keyboard and stdout
represents the screen. But we can force a program to obtain its input from a file
instead of from keyboard using < or >.
Example:
If we use output redirection, everything written to stdout is put into a file. By writing error
messages to stderr instead of stdout, we can guarantee those message will appear on the
screan.
<stdio.h> supports two kinds of files: text file and binary file.
Text Files: represent characters, easy for human to edit.
Binary Files: bytes don’t necessarily represent characters; groups of bytes
might represent other type of data, such as int and float.
Two special characteristics for text file:
When we write a program that reads from a file or writes to a file, we need to consider whether
FILE *fp1, *fp2;
Below 2 operations are the same.
demo < in.dat >out.dat
demo >out.dat <in.dat>
Text files are divided into lines.
Text files may contain a special “end-of file” marker.
You're Reading a Preview

Unlock to view full version

Subscribers Only