It is necessary to open the channel, allocate a buffer, read data, close the channel. The usual approach based on ftell, fseek with the channel does not work: the functions return an error.

How to find out the amount of data that is in the pipe (pipe)?

    1 answer 1

    In general, the only reliable portable way to find out how much data is in a channel is to read this data from the channel.

    You can read in parts, in a pre-selected small buffer. How much will actually be read, so much and there is data in the channel. If the memory is not enough, then allocate by necessity.

    • In some cases, you can find out how much data can be obtained without blocking .. for example, you can find out for sockets. But, cool, your truth: there is no reliable and portable way. Yes, and very often do not need to know. - cy6erGn0m