Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have learn about Console or Terminal input output, where standard streams (stdin, stdout and stderr) use for transmission of data from source to destination.
I want to know that which streams are use for transmission of data from File to Program or from Program to File ?

I am also confused, is FILE pointer a type of stream? Because it helps in transmission of data from program to file as well as file to program. See below..
FILE *stdin
FILE *stdout
FILE *stderr
These are standard streams. Similarly we use to declare FILE pointer in File I/O (FILE *fp), then fp should also a stream. I want to know that can we call fp a stream because it's a FILE pointer just like standard streams ?

And what are the differences between standard streams and binary/text stream ?

What I have tried:

I have learn about standard streams. I have a doubt that is standard streams only work with terminal I/O ?
Posted
Updated 13-Jul-21 8:07am
v3
Comments
KarstenK 13-Jul-21 11:46am    
read the documentation VERY carfully and respect it completly because there isnt ANY safety net between your code and the operating system. ;-)

1 solution

The three standard streams are specifically allocated to console I/O - you dont; use them to access files at all.
Instead, your create a new stream for each file using the fopen function[^] which returns a FILE * - which is a pointer to a stream.

The link shows examples of opening, closing, reading, and writing files.
 
Share this answer
 
v2
Comments
surajgirioffl 13-Jul-21 11:46am    
can we say 'stream' to the FILE * return by fopen() ?
OriginalGriff 13-Jul-21 12:24pm    
The FILE* that fopen returns is a stream - it's just that C is an old language (nearly 50 years old!) and the convention of calling them "streams" hadn't caught on.
They were FILE objects (even stdin and stdout) and the operating system behind them implements streams to handle that.

Or at least it did once UNIX became "popular" and the idea migrated from there into DOS, then MSDOS, then Windows, and so forth.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900