Passing record I/O streams

For record I/O, all reads and writes made by the called program occur at the next record boundary. Because complete records are always read and written, there is no change in the file position across a system() call boundary.

In the example shown in Figure 1, stdout is a variable-length record I/O file.

Figure 1. Example of passing record I/O streams
fwrite("test",1,4,stdout);
fwrite("abc",1,3,stdout);
system("hello");   ------>      int main(void) {
fwrite("def",1,3,stdout);          fwrite("hello world",1,11,stdout)
                                }
The output from this code fragment is as follows:
  test
  abc
  hello world
  def

If freopen() is applied to a C standard stream, creating a stream with type=record, then behavior of the associated I/O stream is undefined across a system() call.