string fgetstring(number fd, string separator, number max_size)
Parameters
fd
[in] A valid file descriptor
separator
[in] String separator
max_size
[in] Maximum number of bytes to be read
Description:
fgetstring reads one item from the input file, fd, formed by the string separator, with maximum size max_size.
If separator contains a value that is not found, then fgetstring will return the content of the input file.
Return value:
Returns the string read.
Example
import standard.C.io
define FILENAME "test.txt"
class Main {
function Main() {
if(!(var fd = fopen( FILENAME, "r" )))
echo "The file " + FILENAME + " was not opened\n";
else {
var buffer = "*";
while (!feof(fd))
echo fgetstring(fd, buffer, 10)+"\n";
fclose(fd);
}
}
}
Input test.txt
First item*Second item*Third item
Results
First item
Second item
Third item