How to resolve the algorithm File size step by step in the Euphoria programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm File size step by step in the Euphoria programming language
Table of Contents
Problem Statement
Verify the size of a file called input.txt for a file in the current working directory, and another one in the file system root.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm File size step by step in the Euphoria programming language
Source code in the euphoria programming language
include file.e
function file_size(sequence file_name)
object x
x = dir(file_name)
if sequence(x) and length(x) = 1 then
return x[1][D_SIZE]
else
return -1 -- the file does not exist
end if
end function
procedure test(sequence file_name)
integer size
size = file_size(file_name)
if size < 0 then
printf(1,"%s file does not exist.\n",{file_name})
else
printf(1,"%s size is %d.\n",{file_name,size})
end if
end procedure
test("input.txt") -- in the current working directory
test("/input.txt") -- in the file system root
You may also check:How to resolve the algorithm Random number generator (device) step by step in the Standard ML programming language
You may also check:How to resolve the algorithm 4-rings or 4-squares puzzle step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Flow-control structures step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Inheritance/Multiple step by step in the D programming language
You may also check:How to resolve the algorithm Regular expressions step by step in the Delphi programming language