prolog change show answer to print into list

When describing a list, always consider using DCGs. In your case, you can very easily obtain what you want with a few simple modifications to your code: show_result(Squares,MaxRow,MaxCol, List) :- phrase(show_result(Squares,MaxRow,MaxCol,1), List). show_result(_,MaxRow,_,Row) –> { Row > MaxRow }, !. show_result(Squares,MaxRow,MaxCol,Row) –> { phrase(show_result(Squares,MaxRow,MaxCol,Row,1), Line) } , [Line], { Row1 is Row+1 }, show_result(Squares,MaxRow,MaxCol,Row1). show_result(_,_,MaxCol,_,Col) … Read more

JTextArea content is not printing in printer fully [closed]

Many Swing components support printing out of the box You could use something as simple as JTextArea.print to get started, for example import java.awt.BorderLayout; import java.awt.Color; import java.awt.EventQueue; import java.awt.Font; import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.awt.print.Paper; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.io.File; import java.io.IOException; import java.util.StringJoiner; import … Read more

C reading from file

Here’s an example of how i would implement PrintFile, hope it helps. #include <stdio.h> int PrintFile(const char *filename); int PrintFile(const char *filename) { FILE *file = fopen(filename, “r”); if (file == NULL) { return -1; } int c = 0; int i = 0; while ((c = fgetc(file)) != EOF) { if (isprint(c)) { fputc(c, … Read more