![]() ![]() In addition, if the input character is '\n', write a second '\n' to the standard output. ![]() For each character you read, write that same character to your standard output. Read a character at a time from the input file. (Don't worry about different end-of-line representations, like the \r\n used by Windows if you open the file in text mode, the C library will take care of translating to and from C's internal '\n' representation.) This problem is easily solved by reading and writing just single characters - and C's I/O functions do implicit buffering, so that won't cause any significant performance problem.Ī "line" is simply a sequence of characters terminated by a newline '\n' character. There's no need to read and write full lines. I'm not sure I should give you the code for a full solution (is this homework?), but I'll give you a quick outline. Any system that has the POSIX-specific functions will have the standard C functions the reverse is not necessarily true. The C language standard provides a higher-level set of functions ( fopen, fclose, and a number of input and output functions), and there's no good reason not to use them here. The open, close, read, and write functions are specific to Unix (actually POSIX).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |