|
Table of Contents
fgetcDescriptionRead a single character from a file at the current stream position. Function prototypeint fgetc <voidptr:hFile> ArgumentsReturn valueThe value of the character in the file at the current stream position, or EOF (-1) if an error occurred. Example// Ask user for filename
string FileName
set FileName <file.OpenDlg "txt" NULL "Text files (*.txt)|*.txt|All files (*.*)|*.*|">
if <iseq 0 <strlen FileName>>
return 0
endif
// Open file
voidptr fp
set fp <fopen FileName "r">
assert fp "Cannot open file!"
// Prepare some variables
char c
set c 0
string s
// Read file character-by-character using fgetc, and add to string
do
set c <fgetc fp>
if <isgt c 0>
set s <strcat s c>
endif
while <isgt c 0>
echo s // Write file contents (in string) to event log
fclose fp // Close file
CommentsNone. See alsoExcept where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
|