How to resolve the algorithm File size step by step in the Bracmat programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm File size step by step in the Bracmat 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 Bracmat programming language

Source code in the bracmat programming language

(getFileSize=
  size
.     fil$(!arg,rb)     {read in binary mode}
    & fil$(,END)        {seek to end of file}
    & fil$(,TEL):?size  {tell where we are}
    & fil$(,SET,-1)     {seeking to an impossible position closes the file, and fails}
  | !size               {return the size}
);

getFileSize$"valid.bra"
113622

getFileSize$"c:\\boot.ini"
211

  

You may also check:How to resolve the algorithm Own digits power sum step by step in the J programming language
You may also check:How to resolve the algorithm Bulls and cows/Player step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Caesar cipher step by step in the Sinclair ZX81 BASIC programming language
You may also check:How to resolve the algorithm Fivenum step by step in the Haskell programming language
You may also check:How to resolve the algorithm Dot product step by step in the Scilab programming language