What does 'stream' mean in C?

后端 未结 6 1988
无人及你
无人及你 2021-02-15 23:40

I\'m reading a section in \'C Primer Plus\' which deals with files, streams and keyboard input. The author connects the concept of stream with files and defines stream as follow

6条回答
  •  盖世英雄少女心
    2021-02-16 00:38

    The people designing C wanted a uniform way of interfacing with different sources of sequential data, like files, sockets, keyboards, USB ports, printers or whatever.

    So they designed one interface that could be applied to all of them. This interface uses properties that are common to all of them.

    To make it easier to talk about the things that could be used through the interface they gave the things a generic name, streams.

    The beauty of using the same interface is that the same code can be used to read from a file as from the keyboard or a socket.

提交回复
热议问题