Archived

This topic is now archived and is closed to further replies.

Files in pascal

This topic is 5508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

var f: file of integer; i: integer; begin assign(f, ''numbers.dat''); rewrite(f); for i := 1 to 10 do write(f, i); close(f); end. When I open numbers.dat with Notepad I get: Why don''t I get 1..10?

Share this post


Link to post
Share on other sites
You''ve stored in the integers in binary format, the same format used by the computer. Depending on your compiler version they will be stored as 2 or 4 bytes each. If you want to store your numbers as plain text (the kind you can read in notepad) you can declare f as a variable of type text, however storing information like this is less efficent, as time is spent converting to and from string representations (it also introduces the change that the text does not represent a valid number, which would generate errors)

Share this post


Link to post
Share on other sites