Lecture12_handout

Lecture12_handout - File Input/Output EE140: Introduction...

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

View Full Document Right Arrow Icon
1 EE140: Introduction to 0t o d u c t o t o Programming Concepts for Engineers Lecture 12 1 File Manipulations File Input/Output File manipulation: Declare a file pointer, all operations involve the file pointer Open a file Close a file Read from a file Write to a file 2 oa Detect the end of file character: EOF Open the file: fopen() Definition: FILE *filepointer; filepointer = fopen(filename, mode); filename can be a fixed name such as "input.txt". It can also be a variable of string type for the file name It is a good idea to check whether a file has been opened properly (see example 1) mode: indicate how the file should be opened ost common modes: 3 Most common modes: “r” – open file for reading FILE * fptr = fopen( test.txt , r ); “w” – open file from scratch for writing, all the contents will be erased without asking. If file does not exist, it will create the file “a” – open file for appending to the end of the file
Background image of page 1

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

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

This note was uploaded on 09/04/2011 for the course EE 150 taught by Professor Lanxiang during the Spring '11 term at Montgomery College.

Page1 / 3

Lecture12_handout - File Input/Output EE140: Introduction...

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

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