Solved

printing a set of files

Posted on 2000-03-02
9
226 Views
Last Modified: 2010-04-02
How to write a program that print a set of files starting each new one on a new page, with a title and a running page count for each file.
0
Comment
Question by:Lora
  • 6
  • 3
9 Comments
 
LVL 22

Expert Comment

by:nietod
Comment Utility
What os?
Are these text files?
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
Do lines need to be wrapped?
0
 

Author Comment

by:Lora
Comment Utility
Text files( MS-DOS)
don't need to be wrapped
help me
0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
Comment Utility
Then you can open the printer port like a file using an fstream.  Open the text files with an fstream and write lines to the file like.

fstream File("C:\\SOMEFILE.TXT",ios_base::in);
fstream Printer("LPT1",ios_base::out);
const int LinesPerPage = 60;
int PageNum = 1;
int LinCnt = 0;

while (!File.eof())
{
   string Lin;

   getline(Lin,File);
   Printer << Lin << endl;
   ++LinCnt;
   if (LinCnt > LinesPerPage)
   {
       Printer << "page number: " << PageNum;
       Printer << '\f';
       ++PageNum;
       LinCnt = 0;
   }
}
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 22

Expert Comment

by:nietod
Comment Utility
Let me know if you have any questions.
0
 

Author Comment

by:Lora
Comment Utility
Please could You help me with this one
Write a program to remove trailing blanks
and tabs from each line of input and delete
entirely blank lines
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
Is this for an assignment?
0
 

Author Comment

by:Lora
Comment Utility
Could You please transform question ?
I am really sorry but I can't understand it
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
The questions you are asking seem like they are for an accademic assignment--homework or school project etc.

For ethical reasons we cannot _give_ answers to accademic questions.  We can provide limited assistance, like you might get from a teacher or tudor.  i.e. we can help you work to a solution, but can't give it.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now