This wiki is out of date, use the continuation of this wiki instead

Fread

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 14:20, 29 May 2007 (edit)
Sandman (Talk | contribs)
m
← Previous diff
Current revision (13:04, 17 July 2007) (edit) (undo)
Sandman (Talk | contribs)
m
 
(One intermediate revision not shown.)
Line 3: Line 3:
==Definition== ==Definition==
-'''INT''' fread ( <'''INT''' filehandle> , <'''VOID''' data> )+'''INT''' fread ( <'''INT''' filehandle> , <'''VARSPACE''' data> )
-Reads the information from a file loaded with [[fopen]] to a variable.+Reads the information from a file loaded with [[fopen]]() to a variable.
== Parameters == == Parameters ==
{| {|
-| '''INT''' filehandle || - Identifier of the file loaded with [[fopen]].+| '''INT''' filehandle || - The [[FileHandle]] of the file returned by [[fopen]]().
|- |-
-| '''VOID''' data || - The data to read from the file (any type of variable). It will be loaded into this variable.+| '''VARSPACE''' data || - The data to read from the file (any type of variable). It will be loaded into this variable.
|} |}
Line 19: Line 19:
== Example == == Example ==
<pre> <pre>
-Process readthing(STRING loadpath);+Process loadthing(STRING loadpath);
Private Private
- handle; // handle for the loaded file + int handle; // handle for the loaded file
- druppels; // here's where the loaded data go+ int druppels; // here's where the loaded data go
- +
Begin Begin
Line 29: Line 28:
fread(handle,druppels); // reads from the file and puts the data in druppels fread(handle,druppels); // reads from the file and puts the data in druppels
fclose(handle); // zipping up after business is done fclose(handle); // zipping up after business is done
- + write(0,0,0,0,druppels); // shows the value of druppels
- write(0,160,100,4,druppels); // let's see what we got here+
End End
- 
</pre> </pre>
Used in example: [[fopen]](), [[fclose]](), [[write]]() Used in example: [[fopen]](), [[fclose]](), [[write]]()

Current revision


Contents

[edit] Definition

INT fread ( <INT filehandle> , <VARSPACE data> )

Reads the information from a file loaded with fopen() to a variable.

[edit] Parameters

INT filehandle - The FileHandle of the file returned by fopen().
VARSPACE data - The data to read from the file (any type of variable). It will be loaded into this variable.

[edit] Returns

INT : The number of bytes read from the file.

[edit] Example

Process loadthing(STRING loadpath);
Private
    int handle;   // handle for the loaded file 
    int druppels; // here's where the loaded data go
Begin

    handle=fopen(loadpath,O_READ); // opens the file in reading mode
    fread(handle,druppels);        // reads from the file and puts the data in druppels
    fclose(handle);                // zipping up after business is done
    write(0,0,0,0,druppels);       // shows the value of druppels

End

Used in example: fopen(), fclose(), write()

Personal tools