Metrologic Optimus S Programming Manual page 201

"c" programming guide
Table of Contents

Advertisement

read
Purpose
To read a specified number of bytes from a DAT file.
Syntax
int read (int fd, char *buffer, int count);
int fd;
char *buffer;
int count;
Example
if ((byte_read = read (fd, buffer, 80)) == -1) puts ("read error!\n");
Description
This routine reads a number of bytes (count) from a DAT file (fd) into the
character array buffer.
Return
If successful, it returns the number of bytes actually read from the file.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their interpretation.
Error Code
2
4
7
8
9
See Also
readln, write, writeln
readln
Purpose
To read a line (null-terminated string) from a DAT file.
int readln (int fd, char *buffer, int max_count);
Syntax
int fd;
char *buffer;
int max_count;
Example
readln (fd, buffer, 80);
Description
This routine reads a null-terminated string from a DAT file (fd) into the
character array buffer.
Characters are read until end-of-file or a null character (\0) is encountered, or
the total number of character read equals the number specified by max_count.
Chapter 3 Terminal Specific Function Library
Reading of data starts at the current position of the file pointer, which is
incremented accordingly when the operation is completed.
Interpretation
File specified by fd does not exist.
File specified by fd is not a DAT file.
Invalid file handle.
File not opened.
The value of count is negative.
/* file handle of the target DAT file */
/* pointer to a buffer where data is read into */
/* number of bytes to be read */
/* file handle of the target DAT file */
/* pointer to a buffer where data is read into */
/* maximum number of bytes to be read */
195

Advertisement

Table of Contents
loading

This manual is also suitable for:

Optimus r

Table of Contents