× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Actually I *did* suggest that Shannon use read() in a prior message. However, I disagree with your assertion that fread is unsuitable. It's not. fread is intended for this type of thing.

The difference between read() and fread() has to do with their origin. read() is a system API -- a component of the operating system. fread() is part of the ILE C runtime library.

read() comes from Unix and is intended to be available with the same syntax on all POSIX compliant systems (read: Unix systems). i5/OS supports it as part of the "Unix-type APIs". It is not part of the C language, however. read() can be expected to exist on any compliant system, even if you don't have a C runtime installed on that system.

However, fread() is part of the C language. Any system that supports ANSI C will always have an fread() function, even if it doesn't make any attempt to conform to POSIX. For example, Windows has an fread() function, but not read().

So the difference isn't really what purpose their suited for -- the difference is what environment you're in. Both functions are suitable for reading binary objects, including image files. (However, fgets() is not -- and that was the original problem.)

In RPG on i5/OS, the distinction doesn't matter much to us, since both are always available. If Shannon prefers to use fread(), let him use fread().


Lim Hock-Chai wrote:
fread() function seems to be designed to read stream file where data in
the file is segmented and, just like record in a database file, each
segment has the same length. Of course, by passing those parameters the
way you suggested would allow Shannon to know the length of data that
this api has read. I'm just curious as why not just use the read()
function. This function seems to be a more suitable function to use
when needing to read an image file.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.