SourcePoint AMD Help

Table of Contents


Read binary data from a file into an array.


[result =] fread(buffer, file_handle)



specifies a debug variable of type ord4 to which the function return value is assigned. If result is not specified, the return value is displayed on the next line of the screen.


is an array variable to receive the data read.


is the file handle returned from a previous fopen command.


The fread function reads binary data from a file previously opened by an fopen command. The data is stored in the array.  The length of each item of data read is specified by the size of the array. The returned value is the number of items or data read.

Note: The feof command should be used to detect end of file.


To read a binary file and write into target memory at address 0:

Command input:

define ord4 file1
define ord4 nItemsRead
define ord4 Buf[1000]
define ptr pMem = 0


file1 = fopen("test.dat", "r")

while (feof(file1) == 0)


   nItemsRead = fread(Buf, file1)

   ord1 pMem length nItemsRead = Buf

   pMem += nItemsRead


fclose (file1)

Related Topics: