1
votes

Can someone show me the code to read multiply strings from file line by line and print it in console? I can write something to file, but have problems, reading it. I've tried

  1. see\1, seen\0;
  2. read(Stream, X)
  3. Some predicates found in google, but without success.
1

1 Answers

0
votes

You could write something like:

read_and_just_print(File) :-
    open(File, read, Stream),
    repeat,
    read_line_to_codes(Stream, X),
    ( X \== end_of_file -> atom_codes(X1,X),writeln(X1), fail ; close(Stream), ! ).