COSC 2P91
Information Technology Week 6a
Brock University
Brock University (Week 6a) Information Technology 1 / 14
COSC 2P91 Information Technology Week 6a Brock University Brock - - PowerPoint PPT Presentation
COSC 2P91 Information Technology Week 6a Brock University Brock University (Week 6a) Information Technology 1 / 14 Introduction to IO Weve already discussed printf and scanf . Lets just revisit them to ensure that we understand what
Brock University (Week 6a) Information Technology 1 / 14
◮ meh
Brock University (Week 6a) Information Technology 2 / 14
◮ Though program < file.txt would probably be more appropriate
◮ And recall that >> can be used for appending
Brock University (Week 6a) Information Technology 3 / 14
Brock University (Week 6a) Information Technology 4 / 14
Brock University (Week 6a) Information Technology 5 / 14
◮ r or rb — open for reading ◮ w or wb — truncate to zero length (or create) file for writing ◮ a or ab — append (open or create) file for writing at EOF ◮ r+, rb+ or r+b — open for update (reading and writing) ◮ w+, wb+ or w+b — truncate to zero length (or create) file for update ◮ a+, ab+ or a+b — append (open or create) file for update; writing at
Brock University (Week 6a) Information Technology 6 / 14
Brock University (Week 6a) Information Technology 7 / 14
◮ This means it only operates on stdin
Brock University (Week 6a) Information Technology 8 / 14
Brock University (Week 6a) Information Technology 9 / 14
◮ Although it might pad the end with a couple null bytes Brock University (Week 6a) Information Technology 10 / 14
◮ Like a numbered reference to an open stream Brock University (Week 6a) Information Technology 11 / 14
◮ By using the terminal command mkfifo, we can create what looks like
◮ We could read and write that buffer from within the same program, or
◮ C itself also has a mkfifo function
◮ e.g. < (./prog) Brock University (Week 6a) Information Technology 12 / 14
◮ You could also start another program with system, but that would
◮ There’s also pipe/pipe2, exec, etc. but this is simpler and more
Brock University (Week 6a) Information Technology 13 / 14
Brock University (Week 6a) Information Technology 14 / 14