Hi!
I would like to print a text file having some records onto the screen while running my program.
Can sumone suggest me the easiest way to do it.
I know I have to open the file using fopen() then what...

>Can sumone suggest me the easiest way to do it.

I think piping is the easiest way to do that :)
( No need for [B]fopen()[/B] :P )

Note:: Not all platforms support piping, though as far as I know Windows, Linux and Unix are all supporting it...

( But actually piping is no real programming so I would rather suggest you to stay with C's I/O Functions )

Hi!
I would like to print a text file having some records onto the screen while running my program.
Can sumone suggest me the easiest way to do it.
I know I have to open the file using fopen() then what...

Can you put more specific question? How to...
- print a file to the same console window in parallel
- print a file to a new (console) window
- open then print a file from your (console) program
... or what else?...

I would like to print it in the same console.
The case is I am writing a file with the help of diffrent functios and in the end i want to print the file for user preview.

Hi!
I would like to print a text file having some records onto the screen while running my program.
Can sumone suggest me the easiest way to do it.
I know I have to open the file using fopen() then what...

Then you check that the return from fopen() was successful
If it was, create a loop and use fgets() inside the loop to read line by line using a buffer. Each line that is successfully obtained by fgets() can be displayed, right away.
End the loop when fgets() cannot read anymore.
Close the file afterward.

commented: Yes. +7
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.