0

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...

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Aia
0

>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 )

0

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?...

0

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.

1

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.

Votes + Comments
Yes.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.