{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec09

lec09 - File and Network I/O CS 2022 Introduction to C...

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

View Full Document Right Arrow Icon
File and Network I/O CS 2022: Introduction to C Instructor: Hussam Abu-Libdeh Cornell University (based on slides by Saikat Guha) Fall 2009, Lecture 9 File and Network I/O CS 2022, Fall 2009, Lecture 9
Background image of page 1

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

View Full Document Right Arrow Icon
Input and Output I Keyboard I/O I Disk I/O I Network I/O File and Network I/O CS 2022, Fall 2009, Lecture 9
Background image of page 2
Streams I In many programming languages, input/output are done in streams I Data exists on the stream, you consume part of it and move on I Examples: I stdout : standard output stream I stderr : standard error output stream I stdin : standard input stream I files I network sockets (network connections) File and Network I/O CS 2022, Fall 2009, Lecture 9
Background image of page 3

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

View Full Document Right Arrow Icon
Output to Terminal I Write a line to stdout I puts("hello world"); I Write a formatted line to stdout I printf("Borat says: Hi %s!\n", i); I Can write to streams other than stdout I fputs("an error message", stderr); fprintf(stderr, "Error on value %d\n", i); File and Network I/O CS 2022, Fall 2009, Lecture 9
Background image of page 4
Input from User (Keyboard) Reading till end of line char buf[128]; fgets(buf, 128, stdin);
Background image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}